1 .\" $NetBSD: xargs.1,v 1.23 2012/10/13 14:18:17 njoly Exp $
3 .\" Copyright (c) 1990, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software contributed to Berkeley by
7 .\" John B. Roll Jr. and the Institute of Electrical and Electronics
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
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.
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
34 .\" @(#)xargs.1 8.1 (Berkeley) 6/6/93
35 .\" $FreeBSD: src/usr.bin/xargs/xargs.1,v 1.40 2010/12/11 08:32:16 joel Exp $
36 .\" $xMach: xargs.1,v 1.2 2002/02/23 05:23:37 tim Exp $
43 .Nd "construct argument list(s) and execute utility"
50 .Op Fl R Ar replacements
61 .Op Ar utility Op Ar argument ...
65 utility reads space, tab, newline and end-of-file delimited strings
66 from the standard input and executes
71 Any arguments specified on the command line are given to
73 upon each invocation, followed by some number of the arguments read
74 from the standard input of
76 This is repeated until standard input is exhausted.
78 Spaces, tabs and newlines may be embedded in arguments using single
80 or double (``"'') quotes or backslashes (``\e'').
81 Single quotes escape all non-single quote characters, excluding newlines,
82 up to the matching single quote.
83 Double quotes escape all non-double quote characters, excluding newlines,
84 up to the matching double quote.
85 Any single character, including newlines, may be escaped by a backslash.
87 The options are as follows:
88 .Bl -tag -width indent
94 characters as separators, instead of spaces and newlines.
95 This is expected to be used in concert with the
102 as a logical EOF marker.
106 for each input line, replacing one or more occurrences of
112 flag is specified) arguments to
114 with the entire line of input.
115 The resulting arguments, after replacement is done, will not be allowed to grow
121 bytes; this is implemented by concatenating as much of the argument
124 as possible, to the constructed arguments to
129 The size limit does not apply to arguments to
133 and furthermore, no replacement will be done on
139 If this option is specified,
141 will use the data read from standard input to replace the first occurrence of
143 instead of appending that data after all other arguments.
144 This option will not affect how many arguments will be read from input
146 or the size of the command(s)
150 The option just moves where those arguments will be placed in the command(s)
154 must show up as a distinct
158 It will not be recognized if, for instance, it is in the middle of a
160 Furthermore, only the first occurrence of the
163 For example, the following command will copy the list of files and
164 directories which start with an uppercase letter in the current
168 .Dl /bin/ls -1d [A-Z]* | xargs -J % cp -rp % destdir
175 If EOF is reached and fewer lines have been read than
179 will be called with the available lines.
181 Set the maximum number of arguments taken from standard input for each
188 standard input arguments if the number of bytes accumulated (see the
190 option) exceeds the specified
192 or there are fewer than
194 arguments remaining for the last invocation of
196 The current default value for
202 in the child process before executing the command.
203 This is useful if you want
205 to run an interactive application.
207 Parallel mode: run at most
213 Echo each command to be executed and ask the user whether it should be
215 An affirmative response,
218 causes the command to be executed, any other response causes it to be
220 No commands are executed if the process is not attached to a terminal.
222 Compatibility with GNU
228 argument at least once, even if
230 input is empty, and it supports a
232 option to inhibit this behavior.
239 argument on empty input, but it supports the
241 option for command-line compatibility with GNU
245 option does nothing in the
249 .It Fl R Ar replacements
250 Specify the maximum number of arguments that
252 will do replacement in.
255 is negative, the number of arguments in which to replace is unbounded.
257 Specify the amount of space (in bytes) that
259 can use for replacements.
264 Set the maximum number of bytes for the command line length provided to
266 The sum of the length of the utility name, the arguments passed to
270 terminators) and the current environment will be less than or equal to
272 The current default value for
278 Echo the command to be executed to standard error immediately before it
283 to terminate immediately if a command line containing
285 arguments will not fit in the specified (or default) command line length.
294 Undefined behavior may occur if
296 reads from the standard input.
300 utility exits immediately (without processing any further input) if a
301 command line cannot be assembled,
303 cannot be invoked, an invocation of
305 is terminated by a signal,
308 exits with a value of 255.
310 .Bl -tag -width /dev/tty -compact
312 used to read responses in prompt mode
316 exits with one of the following values:
317 .Bl -tag -width Ds -compact
321 returned a zero exit status.
323 One or more invocations of
325 returned a nonzero exit status.
329 exited with a 255 exit status.
333 was killed or stopped by a signal.
337 was found but could not be invoked.
343 Some other error occurred.
352 utility is expected to be
359 options are non-standard
361 extensions which may not be available on other operating systems.
365 utility appeared in PWB UNIX 1.0.
366 It made its first BSD appearance in the 4.3 Reno release.
368 The meaning of 123, 124, and 125 exit values and the
370 option were taken from GNU xargs.
374 attempts to invoke another command such that the number of arguments or the
375 size of the environment is increased, it risks
382 utility does not take multibyte characters into account when performing
383 string comparisons for the
387 options, which may lead to incorrect results in some locales.