Tuesday, July 19, 2011

Xargs Commands

http://en.wikipedia.org/wiki/Xargs

xargs -0  The above command uses GNU specific extensions to find and xargs to separate filenames using the null character; -- to grep the filename even with the null charecter.


Xargs -r cp/vi if there is no file, if you use -r then it wont supply any files to cp/vi.



find . -name "*.foo" -print0 | xargs -0 -I {} mv {} /tmp/trash
The above command uses -I to tell xargs to replace {} with the argument list. Note that not all versions of xargs supports the {} syntax. In those cases you may specify a string after -I that will be replaced, e.g.

find . -name "*.foo" -print0 | xargs -0 -I xxx mv xxx /tmp/trash
The above command uses string xxx instead of {} as the argument list marker.

No comments:

Post a Comment