Hamilton LaboratoriesHamilton C shell 2012User guideExternal utilities


Oregon Coast

Previous | Next

        xargs:  Construct argument list(s) and invoke utility

Usage:  xargs [-CtTxh-] [-o<opt>] [-e<escape>] [-X <errlimit>]
             [-n <number>] [-s <size>] [-r<string>]
             [<utility> [<arguments>]]

   xargs will construct a command line consisting of the
   specified utility name and arguments followed by as many
   arguments read from stdin as will fit, given the constraints
   of the operating system or as specified by the -n and -s
   options.  xargs then invokes that constructed command and
   waits for it to complete.  This sequence is repeated until
   end-of-file is detected on stdin or until a constructed
   command exits with return code greater than 1 or some
   other specified value.  (The value of 1 was chosen so that
   commands like grep and fgrep that exit with 1 if no matches
   are found in a given set will continue.)

   Arguments in the input can be separated by unquoted,
   unescaped white space (spaces, tabs, carriage returns or
   newlines).  Quotes can be used around any text containing
   spaces or tabs.  An escape character can be used at the
   end of a line to embed a carriage return-newline sequence.

   The generated command line length is the sum of the size in
   bytes of the utility name and each argument, including a
   space between each argument, a terminating null at the
   end, and any quotes or escape characters as may be
   dictated by the operating system conventions for embedding
   any special characters.


   -C            Start up a copy of C shell to run each command.
   -t            Trace mode.  Each generated command line is
                 written to stderr just prior to invocation.
   -T            Change the title bar for each iteration.
   -x            Terminate if a command line containing the
                 number of arguments specified with the -n option
                 will not fit on the implied or specified command
   -o<opt>       Additional startup options for the C shell.  For
                 example, to get a fast startup, use -oF.
   -e<escape>    Escape character.  By default, xargs will use
                 the character specified by the ESCAPESYM
                 environment variable (if defined) or, if not
                 defined, the circumflex ("^").
   -X <errlimit> Error limit.  If a child command exits with
                 a return code greater than the specified
                 <errlimit>, xargs will exit with that return
                 code from the child.  By default, xargs will
                 exit with the first return code > 1.
   -n <number>   Invoke <utility> with up to <number> arguments.
                 Fewer arguments are used if (a) the command
                 line length exceeds the size limit or (b) the
                 last iteration contains fewer, but not zero
                 operands.  By default, there is no <number>
   -s <size>     Invoke <utility> using as many arguments as
                 possible to produce a command line less than
                 <size> bytes in length.  Fewer arguments
                 are used if (a) the total number of arguments
                 exceeds the <number> limit or (b) end-of-file
                 is encountered on stdin before <size> bytes
                 are accumulated.  By default, there is a
                 <size> limit of 32280 characters for a Win32,
                 POSIX or OS/2 application; for a DOS or Win3.x
                 application, the limit is 110 characters.  If
                 the C shell is being invoked to run a command
                 that's suspected to be a C shell alias, xargs
                 reduces the 32280 limit by 1024 characters to
                 allow for possible expansion.
   -r<string>    Replace the first argument word which consists
                 of only the specified string with argument
                 words read from stdin.  Default string is "%%".
   <utility>     The name of the utility to be invoked.  This
                 can be a fully-qualified or relative pathname
                 or a name resolved by searching the directories
                 listed in the PATH environment variable.  As
                 needed, xargs will look for files with a .csh,
                 .exe, .com or .cmd or .bat extension, auto-
                 matically invoking the C shell for .csh files
                 and the standard command processor for .cmd or
                 .bat files.  If a suitable executable file
                 cannot be found, xargs will assume it may be
                 a C shell alias or built-in command.  If no
                 utility is specified, a built-in echo utility
                 is used.
   <arguments>   Initial options or operands to <utility>.

   -h            Help.  (This screen.)
   --            End of options.

Previous | Next