[X-Unix] Copying to multiple directories
Cloyce D. Spradling
cloyce+xunix at headgear.org
Thu Mar 11 08:47:18 PST 2004
On Thu, Mar 11, 2004 at 03:21:05PM +0000, Stroller wrote:
: What Brian is doing in his posting is DEMONSTRATING the use of the pipe
: ("|") and the `xargs` command (see `man xargs`), suggesting that you
: run this, change "fileA" to the name of the file you actually want to
: copy, and check that it will do what you require. Then run the command
: again, but WITHOUT the `echo` (use the up-arrow key to bring up the
: previous line for editing) to actually perform the copying you require.
I do this sort of thing (using xargs) a lot. Removing the echo works, but
depending on where it is in the line it can be a real PITA. There are
several shortcuts that you can use to make this process painless.
For removing the echo, you can use some a nifty command-line substitution.
This was originally a csh feature, but every other shell on OSX supports
it. Simply type
^echo^
which says "replace the echo in the previous command with nothing".
Another thing I'll do is just leave the command alone and pipe its output
to sh. That is:
ls -d /Users/*/Library | xargs -I % echo cp fileA % | sh
That is quick and easy and not too much typing. If you want to watch it
happen, just add a '-x':
ls -d /Users/*/Library | xargs -I % echo cp fileA % | sh -x
--
Cloyce
More information about the X-Unix
mailing list