xref: /netbsd-src/usr.bin/xargs/xargs.1 (revision cda4f8f6ee55684e8d311b86c99ea59191e6b74f)
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" John B. Roll Jr. and the Institute of Electrical and Electronics
6.\" Engineers, Inc.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\"    must display the following acknowledgement:
18.\"	This product includes software developed by the University of
19.\"	California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\"    may be used to endorse or promote products derived from this software
22.\"    without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\"	@(#)xargs.1	5.5 (Berkeley) 6/27/91
37.\"
38.Dd June 27, 1991
39.Dt XARGS 1
40.Os
41.Sh NAME
42.Nm xargs
43.Nd construct argument list(s) and execute utility.
44.Sh SYNOPSIS
45.Nm xargs
46.Op Fl t
47.Oo
48.Op Fl x
49.Fl n Ar number
50.Oc
51.Op Fl s Ar size
52.Oo
53.Ar utility
54.Op Ar argument Ar ...
55.Oc
56.Sh DESCRIPTION
57The
58.Nm xargs
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
74or double quotes or backslashes.
75Single quotes escape all non-single quote characters, excluding newlines,
76up to the matching single quote.
77Double quotes escape all non-double quote characters, excluding newlines,
78up to the matching double quote.
79Any single character, including newlines, may be escaped by a backslash.
80.Pp
81The options are as follows:
82.Bl -tag -width indent
83.It Fl n Ar number
84Set the maximum number of arguments taken from standard input for each
85invocation of the utility.
86An invocation of
87.Ar utility
88will use less than
89.Ar number
90standard input arguments if the number of bytes accumulated (see the
91.Fl s
92option) exceeds the specified
93.Ar size
94or there are fewer than
95.Ar number
96arguments remaining for the last invocation of
97.Ar utility .
98The current default value for
99.Ar number
100is 5000.
101.It Fl s Ar size
102Set the maximum number of bytes for the command line length provided to
103.Ar utility .
104The sum of the length of the utility name and the arguments passed to
105.Ar utility
106(including NULL terminators) will be less than or equal to this number.
107The current default value for
108.Ar size
109is
110.Dv ARG_MAX
111- 2048.
112.It Fl t
113Echo the command to be executed to standard error immediately before it
114is executed.
115.It Fl x
116Force
117.Nm xargs
118to terminate immediately if a command line containing
119.Ar number
120arguments will not fit in the specified (or default) command line length.
121.El
122.Pp
123If no
124.Ar utility
125is specified,
126.Xr echo 1
127is used.
128.Pp
129Undefined behavior may occur if
130.Ar utility
131reads from the standard input.
132.Sh DIAGNOSTICS
133.Nm xargs
134exits with one of the following values:
135.Bl -tag -width Ds -compact
136.It 0
137All invocations of
138.Ar utility
139returned a zero exit status.
140.It 123
141One or more invocations of
142.Ar utility
143returned a nonzero exit status.
144.It 124
145The
146.Ar utility
147exited with a 255 exit status.
148.It 125
149The
150.Ar utility
151was killed or stopped by a signal.
152.It 126
153The
154.Ar utility
155was found but could not be invoked.
156.It 127
157The
158.Ar utility
159could not be found.
160.It 1
161Some other error occured.
162.El
163.Sh "SEE ALSO"
164.Xr echo 1 ,
165.Xr find 1
166.Sh STANDARDS
167.Nm xargs
168is expected to be
169.St -p1003.2
170compliant.
171.Sh HISTORY
172The meaning of 123, 124, and 125 exit values were taken from GNU xargs.
173