2 ms·
You can use another construct built into find that negates the need for a for loop: find . -name foo -exec do something to {} \; For example: find .
by geocrasher 5y ago
You can use another construct built into find that negates the need for a for loop:
find . -name foo -exec do something to {} \;
For example:
find . type f -exec chmod 644 {} \;
find . -size +1G -exec ls -lh {} \; |awk '{ print $5" "$9 }'
- t43562 5y agoYes, I think most of the time this is all you need. I just like the for loop because I can do filename manipulations in the loop and the input to the loop doesn't always have to be find - it can be "grep <something> -l ./" for example - so I use it even if it's verbose because it's only one thing to remember. Perhaps that is a problem with bash and the tools - there are so many features that take years to discover. Every few weeks I come across a new one.