xargs
Last modified: December 2, 2006
xargs is an UNIX command. When should you use xargs? When the output of a command is the command-line options of another command, use xargs in conjunction with pipes. When the output of a command is the input of another command, use pipes.
Example:
find . -type f -mtime -1 -print|xargs pr -n |lp
With no options, xargs reads standard input, but only writes enough arguments to standard output as to not overflow the command-line buffer. Thus, if needed, xargs forces multiple executions of pr -n|lp.
Another example: remove all files with a txt extension
find . -type f -name "*.txt" -print|xargs rm
References:


Recent Comments