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