You can't really influence environment "horizontally" in the pipe - the processes in a
... p_n | p_n+1 | p_n+2 ... pipe are spawned by the same shell interpreter, hence there is no way to change environment variable of say
p_m, echii is in the same pipeline.
If you just need to do a simple transformation of the filenames, which can be achieved with regular expressions, then the Perl example
rename should do. You might want/need to use
xargs to prevent problems with escaping
find ... -print0 | xargs -0 rename "regexps"
which delimits the filenames with NUL bytes (NUL and backslash are the only characters that are generally forbidden to appear in a filename).
If your file names are well-behaved (and hence you can assume, that you don;'t need any special escaping of "weird" characters like quotes, spaces and separators used in the regexps), you can also do something quick and dirty like:
find ... | sed -r "regexps" | sh -
In this case the regexps have to create a valid command invoking
mv (or something else that does the desired action) - it may look like:
"s|^.*$|mv -vi & &.old|"
which produces something like
mv -vi /etc/a2ps.cfg /etc/a2ps.cfg.old
mv -vi /etc/aclocal_dirlist /etc/aclocal_dirlist.old
If the simple regular expression is not powerful enough or would be too cumbersome, just write a simple script that processes filenames and does the rename/move itself and call it either from find directly (
-exec +) or through
Finally, if you just want to move copy bunch of files to another directory, use the
-t option of
cp in the GNU coreutils also has the
--parents option, which copies the source with its complete path.