copying files with same name

Dru dlavigne6 at sympatico.ca
Mon Feb 16 13:46:05 PST 2004


Okay, I must be missing something obvious here. How do you do a batch copy
while renaming the destination files? I want to copy all of the configure
scripts in /usr/ports to ~/scripts. I can get find to find the files, I
can get sed to rename them, but I can't get the timing down right.

cp -v `find /usr/ports -name configure -print | sed 's:/:=:g'` .

renames the files nicely (so they're not all named configure), but does it
too soon--the source no longer exists.

cp -v `find /usr/ports -name configure -print -exec sed 's:/:=:g' {} \;` .

gives a syntax error (missing }) and

cp -v `find /usr/ports -name configure -print | sed 's:/:=:g'` .

has sed complain of extra characters at the end of a p command, followed
by all my destination files being named configure.

Is there a way to do this as a one-liner, or does one have to write a
shell script with a while loop?

Dru


More information about the freebsd-questions mailing list