Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Feb 2004 16:49:37 -0500 (EST)
From:      Dru <dlavigne6@sympatico.ca>
To:        questions@freebsd.org
Subject:   copying files with same name
Message-ID:  <20040216163818.R609@genisis.domain.org>

next in thread | raw e-mail | index | archive | help

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040216163818.R609>