1.\" $NetBSD: xargs.1,v 1.16 2002/10/02 10:09:51 wiz Exp $ 2.\" 3.\" Copyright (c) 1990, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" This code is derived from software contributed to Berkeley by 7.\" John B. Roll Jr. and the Institute of Electrical and Electronics 8.\" Engineers, Inc. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 3. All advertising materials mentioning features or use of this software 19.\" must display the following acknowledgement: 20.\" This product includes software developed by the University of 21.\" California, Berkeley and its contributors. 22.\" 4. Neither the name of the University nor the names of its contributors 23.\" may be used to endorse or promote products derived from this software 24.\" without specific prior written permission. 25.\" 26.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36.\" SUCH DAMAGE. 37.\" 38.\" @(#)xargs.1 8.1 (Berkeley) 6/6/93 39.\" 40.Dd December 21, 1999 41.Dt XARGS 1 42.Os 43.Sh NAME 44.Nm xargs 45.Nd "construct argument list(s) and execute utility" 46.Sh SYNOPSIS 47.Nm 48.Op Fl 0 49.Op Fl p 50.Op Fl t 51.Oo Op Fl x 52.Fl n Ar number 53.Oc 54.Op Fl s Ar size 55.Op Ar utility Op Ar arguments ... 56.Sh DESCRIPTION 57The 58.Nm 59utility reads space, tab, newline and end-of-file delimited arguments 60from the standard input and executes the specified 61.Ar utility 62with them as arguments. 63.Pp 64The utility and any arguments specified on the command line are given 65to the 66.Ar utility 67upon each invocation, followed by some number of the arguments read 68from standard input. 69The 70.Ar utility 71is repeatedly executed until standard input is exhausted. 72.Pp 73Spaces, tabs and newlines may be embedded in arguments using single 74(``\ '\ '') 75or double (``"'') quotes or backslashes (``\e''). 76Single quotes escape all non-single quote characters, excluding newlines, 77up to the matching single quote. 78Double quotes escape all non-double quote characters, excluding newlines, 79up to the matching double quote. 80Any single character, including newlines, may be escaped by a backslash. 81.Pp 82The options are as follows: 83.Bl -tag -width Fl 84.It Fl 0 85Use NUL 86(``\e0'') 87instead of whitespace as the argument separator. 88This can be used in conjunction with the 89.Fl print0 90option of 91.Xr find 1 . 92.It Fl n Ar number 93Set the maximum number of arguments taken from standard input for each 94invocation of the utility. 95An invocation of 96.Ar utility 97will use less than 98.Ar number 99standard input arguments if the number of bytes accumulated (see the 100.Fl s 101option) exceeds the specified 102.Ar size 103or there are fewer than 104.Ar number 105arguments remaining for the last invocation of 106.Ar utility . 107The current default value for 108.Ar number 109is 5000. 110.It Fl p 111Prompt mode: immediately before each command execution the user is prompted 112whether to execute the command instance. 113If an affirmative response is read from 114.Pa /dev/tty 115the command will be executed; otherwise this particular invocation will be 116skipped. 117This option implies the 118.Fl t 119option. 120.It Fl s Ar size 121Set the maximum number of bytes for the command line length provided to 122.Ar utility . 123The sum of the length of the utility name and the arguments passed to 124.Ar utility 125(including 126.Dv NULL 127terminators) will be less than or equal to this number. 128The current default value for 129.Ar size 130is 131.Dv ARG_MAX 132- 4096. 133.It Fl t 134Echo the command to be executed to standard error immediately before it 135is executed. 136.It Fl x 137Force 138.Nm 139to terminate immediately if a command line containing 140.Ar number 141arguments will not fit in the specified (or default) command line length. 142.El 143.Pp 144If no 145.Ar utility 146is specified, 147.Xr echo 1 148is used. 149.Pp 150Undefined behavior may occur if 151.Ar utility 152reads from the standard input. 153.Pp 154The 155.Nm 156utility exits immediately (without processing any further input) if a 157command line cannot be assembled, 158.Ar utility 159cannot be invoked, an invocation of the utility is terminated by a signal 160or an invocation of the utility exits with a value of 255. 161.Sh EXIT STATUS 162.Nm 163exits with one of the following values: 164.Bl -tag -width Ds -compact 165.It 0 166All invocations of 167.Ar utility 168returned a zero exit status. 169.It 123 170One or more invocations of 171.Ar utility 172returned a nonzero exit status. 173.It 124 174The 175.Ar utility 176exited with a 255 exit status. 177.It 125 178The 179.Ar utility 180was killed or stopped by a signal. 181.It 126 182The 183.Ar utility 184was found but could not be invoked. 185.It 127 186The 187.Ar utility 188could not be found. 189.It 1 190Some other error occurred. 191.El 192.Sh FILES 193.Bl -tag -width /dev/tty -compact 194.It Pa /dev/tty 195used to read responses in prompt mode 196.El 197.Sh SEE ALSO 198.Xr echo 1 , 199.Xr find 1 200.Sh STANDARDS 201The 202.Nm 203utility is expected to be 204.St -p1003.2 205compliant. 206.Sh HISTORY 207The 208.Nm xargs 209command appeared in PWB Unix 1.0. 210It made its first BSD appearance in the 4.3 Reno release. 211.Pp 212The meaning of 123, 124, and 125 exit values and the 213.Fl 0 214option were taken from GNU xargs. 215