pavement

Xargs

From FreeBSDwiki
Revision as of 10:03, 30 May 2006 by Jimbo (Talk | contribs)
Jump to: navigation, search

xargs is a command useful for acting upon the output of an earlier command; for instance, you could pipe the output of the find command to xargs rm to recursively delete all .tmp files below the current directory:

server# find . -name "*.tmp" | xargs rm

from the manpage:

    The xargs utility reads space, tab, newline and end-of-file delimited
    strings from the standard input and executes utility with the strings as
    arguments.
    Any arguments specified on the command line are given to utility upon
    each invocation, followed by some number of the arguments read from the
    standard input of xargs.  The utility is repeatedly executed until stan-
    dard input is exhausted.
Personal tools