xargs Command Purpose Constructs parameter lists and runs commands. Syntax xargs [ -p ] [ -t ] [ -n Number] [ -l [ Number ] ] [ -x ] [ -e[ EndOfFile ] ] [ -i[ String ] ] [ -xSize ] [ CommandLine ] Description The xargs command runs a command line. It constructs the command line by combining the CommandLine parameter, a string containing a command and its flags or parameters, with additional parameters read from standard input. It constructs the command line as many times as necessary to process all input parameters. The default CommandLine parameter is the echo command. Parameters read from standard input are character strings delim- ited by one or more spaces, tabs, or new-line characters. You can embed a space or a tab in parameters by preceding it with a \ (backslash) or by putting it in quotation marks. The xargs command reads characters enclosed in single or double quotation marks as literals and removes the delimiting quotation marks. It always discards empty lines. The xargs command evaluates the size of the current environment when determining how many arguments to add to the commands it generates. The size of the current environment plus the size of the command line generated by the xargs command cannot exceed the ARG_MAX value in length (see the E2BIG error in the execvp sub- routine). The xargs command ends if both this limit is reached and the -x flag is used. If the -x flag is not used, the xargs command uses as many arguments as will fit within the ARG_MAX limit on the first pass, and then makes successive passes using any remaining arguments until all specified arguments have been used. Note: The xargs command ends if it cannot run the CommandLine parameter or if it receives a return code of -1. When the Com- mandLine parameter calls a shell procedure, the shell procedure should explicitly exit with an appropriate value to avoid accidentally returning a value of -1. Flags -e[EndOfFile] Sets the logical end-of-file string. The xargs command reads standard input until it encounters either an end- of-file character or the logical EOF string. If you do not specify the -e flag, the default EndOfFile parameter is _ ( the underline character). If you specify -e without the EndOfFile parameter, the xargs command interprets the underline character as a literal character rather than as an end-of-file marker. -i[String] Takes an entire line as a single parameter and inserts it in each instance of the String variable found in the CommandLine parameter. A maximum of five parameters in the CommandLine parameter can each contain one or more instances of the String variable. The xargs command discards spaces and tabs at the beginning of each line. The command line constructed can- not be larger than 255 bytes. The default String variable is { } (braces). This flag also turns on the -x flag. -l[Number] Runs the CommandLine parameter with the specified number of nonempty parameter lines read from standard input. The last invocation of the CommandLine parameter can have fewer parameter lines if fewer than the specified number remain. A line ends with the first new-line character unless the last char- acter of the line is a space or a tab. A trailing space or tab indicates a continuation through the next nonempty line. The de- fault value of the Number variable is 1. This flag turns on the -x flag. -nNumber Runs the CommandLine parameter using as many standard input parameters as possible, up to the maximum specified by the Number variable.The xargs command uses fewer parameters if their total size is greater than the number of bytes specified by the -sSize flag. It also uses fewer parameters for the last invoca- tion if fewer than the number of parameters specified by the Number variable remain. When the -x flag is present, each Number variable must fit the size limitation specified by the -x flag. -p Asks whether to run the CommandLine parameter. It displays the constructed command line, followed by a ?...(question mark, dot dot dot) prompt. Enter an affirmative response specific to the locale to run the CommandLine parameter. Any other response causes the xargs command to skip that particular invocation of the parameter. You are asked about each invocation. -sSize Sets the maximum total size of each parameter list. The Size variable must be a positive integer less than or equal to LINE_MAX. The default size is LINE_MAX bytes. Note: The byte count for the Size variable includes one extra byte for each parameter, plus the number of bytes in the command name. -t Echoes the CommandLine parameter and each constructed parame- ter list to standard error. -x Stops running the xargs command if any parameter list is greater than the number of bytes specified by the -s flag. This flag is turned on if you specify either the -i or -l flag. If you do not specify the -i, -l, or -n flag, the total length of all parameters must be within the limit specified by the Size variable. Exit Status This command returns the following exit values: 0 All invocations of the CommandLine parameter returned exit status 0 1-125 Indicates one of the following errors: A command line meeting the specified requirements could not be assembled. One or more invocations of the CommandLine parameter returned a non-zero exit status. Some other error occurred. 126 Found but could not invoke the command specified in the CommandLine parameter. 127 Could not find the command specified in the CommandLine parameter. Examples 1. To use a command on files whose names are listed in a file, enter: xargs lint -a