Re: Advantages over find?
Why such -- rather complicated -- bash magic?
What's so bad on just teaching people clever use of
standard tools as sh(1), find(1), xargs(1), sed(1) etc?
For example, renaming .tgz to .tar.gz can be done
with a simple command line:
find $some_path -type f -name \*.tgz | sed
's/\(.*\)\.tgz/mv & \1.tar.gz/' | sh
When unsure, run that command without the trailing |
sh to see what would happen. Or run it with | sh -x to
see *what* actually happens.
Note that this example is a *oneliner*, so with a little
bit more magic, you could easily make it robust
against weird filenames (containing whitespace,
quotes and thelike). However, neither ff nor a
combination of find(1), sed(1) and sh(1) as above
can handle filenames with newlines. You've to use
find ... -print0 | xargs -0 for this, which unfortunately is
a GNU extension.