[Linux-disciples] xargs -0

Adam Rosi-Kessel adam at rosi-kessel.org
Tue Jul 11 14:48:45 EDT 2006


I think you're asking a different question.

Isn't what you want

grep -Zirl [pattern] [sourcePath] | xargs -i cp "{}" [destPath]

??

(this won't necessarily deal with all escaping issues, but I think that's a
different topic than your question)

Stephen R Laniel wrote:
> How does one use xargs -0 along with commands that an
> argument to go in a specific place? E.g., what do I do if I
> want to copy a bunch of files into a given directory? I'd do
> something like
> 
> [command] |xargs -0 cp [destDir]
> 
> but that won't work, because xargs doesn't know that destDir
> is supposed to be the final argument. With 'mv', one can do
> better, because it has a --target-directory option:
> 
>        --target-directory=DIRECTORY
> 	      move all SOURCE arguments into DIRECTORY
> 
> So then we could do, e.g.,
> 
> grep -Zirl [pattern] [sourcePath] |xargs -0 cp --target-directory=[destPath]
> 
> But 'cp' has no such argument. In general, do we have to
> rely on the kindness of other commands to output
> null-separated filenames?
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Linux-disciples mailing list
> Linux-disciples at lists.bostoncoop.net
> http://lists.bostoncoop.net/mailman/listinfo/linux-disciples



More information about the Linux-disciples mailing list