[CentOS] tar with pipe [SOLVED]

Kai centos.newsgroup at sandsengen.com
Sun Sep 25 18:08:31 UTC 2005

Joshua Baker-LePain wrote:
> On Sun, 25 Sep 2005 at 6:52pm, Kai wrote
>> Joshua Baker-LePain wrote:
>>> *However*, that will keep the directory structure.  Why not just use cp?
>>> find ../ -name '*.mp3' -o -name '*.ogg' -print0 | xargs -0 -i cp \{} .
> xargs takes whatever comes in stdin and puts in after the commands which 
> follow it.  If you give 'xargs' the '-i' flag, it instead takes what 
> comes in on stdin and puts it whereever you put the '\{}' (note the 
> location of the \).  'find | xargs' is *much* faster than 'find -exec' 
> b/c you're not spawning a new process for every hit.  The '-print0' to 
> find and '-0' to xargs use nulls to delimit each entry rather than 
> whitespace -- this lets the command work on files/directory names with 
> spaces in them.
Thank you soo much, I am very grateful. This has given me headache, 
really. You solved my problem. I do not fully understand the command:
the argument \ standing before {} and the .

This confuses me a little bit because my understanding was that \ closed 
the command line and there should be nothing after.
Also it maid me understand how to use the -exec. Again thank you.

find ../ -name '*.mp3' -o -name '*.ogg' -exec cp {} . \;

More information about the CentOS mailing list