xargs
xargs is a Unix program available on most Unix systems , including FreeBSD , Linux , Solaris, and ReactOS . It is used to convert standard input into command lines . xargs first appeared in PWB / UNIX .
functionality
xargs accepts text via standard input (usually via pipes). This is given to the specified argument as a command line argument.
Xargs is often used with find :
$ find / -name '*.o' | xargs rm
This command removes all files that end in '.o' from the computer's file system.
find alone would output this:
$ find / -name '*.o' ./dev/proj/a.o ./dev/proj/b.o
xargs converts this into the call
$ rm ./dev/proj/a.o ./dev/proj/b.o
around. Since the number of command line arguments cannot be arbitrarily large under many operating systems, xargs divides too many arguments into several calls if necessary.
Web links
- FreeBSD: xargs (1)
- Jochen Gruse: xargs (1) - your friend and helper. pro-linux.de, September 24, 2001, accessed May 27, 2013 .