There appear be a number of ways to do this including loops in shell script, find and xargs. Which of these is best, and which is most portable?
for the current directory as the root of the tree or in general:
|
|||||||||||||||
|
|
Use the
The The |
||||
|
|
|
If portability is an issue I would stay away from shell-specific ways of doing it (there are lots of people using lots of different shells, but in general find and xargs are really basic tools that no one would dare change in a radical way). Using basic arguments of find and xargs should give you a more portable solution. |
||||
|
|
|
If grouping arguments together is acceptable, find | xargs will probably give better performance, since it will execute the command a lot fewer times than find -exec. If you want to execute the command each time for each file or execute in the subdirectory of the file you should probably use find -exec or -execdir. As a rule, it's preferable to stay away from shell-specific loops; find & xargs are enough for most scenarios. |
|||
|
|
|
Make sure the version of the command you're using doesn't already have a flag for recursive operation. :) |
|||
|
|
Works best for me. |
|||||
|
