xref: /freebsd/usr.bin/xargs/xargs.1 (revision afe61c15161c324a7af299a9b8457aba5afc92db)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  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	8.1 (Berkeley) 6/6/93
37.\"
38.Dd June 6, 1993
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 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 xargs
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
59arguments.
60.Pp
61The utility and any arguments specified on the command line are given
62to the
63.Ar utility
64upon each invocation, followed by some number of the arguments read
65from standard input.
66The
67.Ar utility
68is repeatedly executed until standard input is exhausted.
69.Pp
70Spaces, tabs and newlines may be embedded in arguments using single
71(``\ '\ '')
72.Ek
73or double (``"'') quotes or backslashes (``\e'').
74Single quotes escape all non-single quote characters, excluding newlines,
75up to the matching single quote.
76Double quotes escape all non-double quote characters, excluding newlines,
77up to the matching double quote.
78Any single character, including newlines, may be escaped by a backslash.
79.Pp
80The options are as follows:
81.Bl -tag -width indent
82.It Fl n Ar number
83Set the maximum number of arguments taken from standard input for each
84invocation of the utility.
85An invocation of
86.Ar utility
87will use less than
88.Ar number
89standard input arguments if the number of bytes accumulated (see the
90.Fl s
91option) exceeds the specified
92.Ar size
93or there are fewer than
94.Ar number
95arguments remaining for the last invocation of
96.Ar utility .
97The current default value for
98.Ar number
99is 5000.
100.It Fl s Ar size
101Set the maximum number of bytes for the command line length provided to
102.Ar utility .
103The sum of the length of the utility name and the arguments passed to
104.Ar utility
105(including
106.Dv NULL
107terminators) will be less than or equal to this number.
108The current default value for
109.Ar size
110is
111.Dv ARG_MAX
112- 2048.
113.It Fl t
114Echo the command to be executed to standard error immediately before it
115is executed.
116.It Fl x
117Force
118.Nm xargs
119to terminate immediately if a command line containing
120.Ar number
121arguments will not fit in the specified (or default) command line length.
122.El
123.Pp
124If no
125.Ar utility
126is specified,
127.Xr echo 1
128is used.
129.Pp
130Undefined behavior may occur if
131.Ar utility
132reads from the standard input.
133.Pp
134The
135.Nm xargs
136utility exits immediately (without processing any further input) if a
137command line cannot be assembled,
138.Ar utility
139cannot be invoked, an invocation of the utility is terminated by a signal
140or an invocation of the utility exits with a value of 255.
141.Pp
142The
143.Nm xargs
144utility exits with a value of 0 if no error occurs.
145If
146.Ar utility
147cannot be invoked,
148.Nm xargs
149exits with a value of 127.
150If any other error occurs,
151.Nm xargs
152exits with a value of 1.
153.Sh SEE ALSO
154.Xr echo 1 ,
155.Xr find 1
156.Sh STANDARDS
157The
158.Nm xargs
159utility is expected to be
160.St -p1003.2
161compliant.
162