1 .TH XARGS 1 \" -*- nroff -*-
3 xargs \- build and execute command lines from standard input
9 [\fB\-e\fR[\fIeof-str\fR]]
10 [\fB\-\-eof\fR[=\fIeof-str\fR]]
12 [\fB\-d \fIdelimiter\fR]
13 [\fB\-\-delimiter \fIdelimiter\fR]
14 [\fB\-I \fIreplace-str\fR]
15 [\fB\-i\fR[\fIreplace-str\fR]]
16 [\fB\-\-replace\fR[=\fIreplace-str\fR]]
17 [\fB\-l\fR[\fImax-lines\fR]]
18 [\fB\-L \fImax-lines\fR]
19 [\fB\-\-max\-lines\fR[=\fImax-lines\fR]]
20 [\fB\-n \fImax-args\fR]
21 [\fB\-\-max\-args\fR=\fImax-args\fR]
22 [\fB\-s \fImax-chars\fR]
23 [\fB\-\-max\-chars\fR=\fImax-chars\fR]
24 [\fB\-P \fImax-procs\fR]
25 [\fB\-\-max\-procs\fR=\fImax-procs\fR]
26 [\fB\-\-interactive\fR]
29 [\fB\-\-no\-run\-if\-empty\fR]
30 [\fB\-\-arg\-file\fR=\fIfile\fR]
31 [\fB\-\-show\-limits\fR]
34 [\fIcommand\fR [\fIinitial-arguments\fR]]
38 documents the GNU version of
41 reads items from the standard input, delimited by blanks (which can be
42 protected with double or single quotes or a backslash) or newlines,
47 one or more times with any
49 followed by items read from standard input. Blank lines on the
50 standard input are ignored.
54 is built up until it reaches a system-defined limit (unless the
58 options are used). The specified
60 will be invoked as many times as necessary to use up the list of input
61 items. In general, there will be many fewer invocations of
63 than there were items in the input. This will normally have
64 significant performance benefits. Some commands can usefully be
65 executed in parallel too; see the
69 Because Unix filenames can contain blanks and newlines, this default
70 behaviour is often problematic; filenames containing blanks
71 and/or newlines are incorrectly processed by
73 In these situations it is better to use the
76 prevents such problems. When using this option you will need to
77 ensure that the program which produces the input for
79 also uses a null character as a separator. If that program is
84 option does this for you.
86 If any invocation of the command exits with a status of 255,
88 will stop immediately without reading any further input. An error
89 message is issued on stderr when this happens.
93 .BI "\-\-arg\-file=" file
99 instead of standard input. If you use this option, stdin remains
100 unchanged when commands are run. Otherwise, stdin is redirected
110 Input items are terminated by a null character instead of by
111 whitespace, and the quotes and backslash are not special (every
112 character is taken literally). Disables the end of file string, which
113 is treated like any other argument. Useful when input items might
114 contain white space, quote marks, or backslashes. The GNU find
115 \-print0 option produces input suitable for this mode.
119 .BI "\-\-delimiter=" delim
123 Input items are terminated by the specified character. Quotes and
124 backslash are not special; every character in the input is taken
125 literally. Disables the end-of-file string, which is treated like any
126 other argument. This can be used when the input consists of simply
127 newline-separated items, although it is almost always better to design
130 where this is possible. The specified
131 delimiter may be a single character, a C-style character escape such
134 or an octal or hexadecimal escape code. Octal and hexadecimal
135 escape codes are understood as for the
137 command. Multibyte characters are not supported.
141 Set the end of file string to \fIeof-str\fR. If the end of file
142 string occurs as a line of input, the rest of the input is ignored.
147 is used, no end of file string is used.
150 .BR "\-\-eof" [\fI=eof-str\fR]
153 .BR \-e [ \fIeof-str\fR]
154 This option is a synonym for the
159 because it is POSIX compliant while this option is not. If
160 \fIeof-str\fR is omitted, there is no end of file string. If neither
164 is used, no end of file string is used.
167 Print a summary of the options to
171 .BI \-I " replace-str"
172 Replace occurrences of \fIreplace-str\fR in the initial-arguments with
173 names read from standard input. Also, unquoted blanks do not
174 terminate input items; instead the separator is the newline character.
182 .BR "\-\-replace" [\fI=replace-str\fR]
185 .BR \-i "[\fIreplace-str\fR]"
186 This option is a synonym for
192 argument is missing, the effect is the same as
194 This option is deprecated; use
199 Use at most \fImax-lines\fR nonblank input lines per command line.
200 Trailing blanks cause an input line to be logically continued on the
201 next input line. Implies
205 .BR \-\-max-lines "[=\fImax-lines\fR]"
208 .BR \-l "[\fImax-lines\fR]"
215 argument is optional. If
217 is not specified, it defaults to one. The
219 option is deprecated since the POSIX standard specifies
224 .BR "\-\-max\-args" =\fImax-args\fR
228 Use at most \fImax-args\fR arguments per command line. Fewer than
230 arguments will be used if the size (see the
232 option) is exceeded, unless the
234 option is given, in which case
242 Prompt the user about whether to run each command line and read a line
243 from the terminal. Only run the command line if the response starts
244 with `y' or `Y'. Implies
248 .B \-\-no\-run\-if\-empty
252 If the standard input does not contain any nonblanks, do not run the
253 command. Normally, the command is run once even if there is no input.
254 This option is a GNU extension.
257 .BR \-\-max\-chars "=\fImax-chars\fR"
261 Use at most \fImax-chars\fR characters per command line, including the
262 command and initial-arguments and the terminating nulls at the ends of
263 the argument strings. The largest allowed value is system-dependent,
264 and is calculated as the argument length limit for exec, less the size
265 of your environment, less 2048 bytes of headroom. If this value is
266 more than 128KiB, 128Kib is used as the default value; otherwise, the
267 default value is the maximum. 1KiB is 1024 bytes.
269 automatically adapts to tighter constraints.
276 Print the command line on the standard error output before executing
280 Print the version number of
284 .B "\-\-show\\-limits"
285 Display the limits on the command-line length which are imposed by the
288 choice of buffer size and the
290 option. Pipe the input from
293 .BR --no-run-if-empty )
303 Exit if the size (see the
308 .BR \-\-max\-procs "=\fImax-procs\fR"
314 processes at a time; the default is 1. If
318 will run as many processes as
319 possible at a time. Use the
325 otherwise chances are that only one exec will be done.
328 .B find /tmp \-name core \-type f \-print | xargs /bin/rm \-f
333 in or below the directory
335 and delete them. Note that this will work incorrectly if there are
336 any filenames containing newlines or spaces.
338 .B find /tmp \-name core \-type f \-print0 | xargs \-0 /bin/rm \-f
343 in or below the directory
345 and delete them, processing filenames in such a way that file or
346 directory names containing spaces or newlines are correctly handled.
349 .B find /tmp \-depth \-name core \-type f \-delete
354 in or below the directory
356 and delete them, but more efficiently than in the previous example
357 (because we avoid the need to use
363 and we don't need the extra
369 .B cut \-d: \-f1 < /etc/passwd | sort | xargs echo
372 Generates a compact listing of all the users on the system.
376 .B xargs sh -c 'emacs \(dq$@\(dq < /dev/tty' emacs
379 Launches the minimum number of copies of Emacs needed, one after the
380 other, to edit the files listed on
382 standard input. This example achieves the same effect as BSD's
384 option, but in a more flexible and portable way.
390 exits with the following status:
393 123 if any invocation of the command exited with status 1-125
394 124 if the command exited with status 255
395 125 if the command is killed by a signal
396 126 if the command cannot be run
397 127 if the command is not found
398 1 if some other error occurred.
401 Exit codes greater than 128 are used by the shell to indicate that
402 a program died due to a fatal signal.
403 .SH "STANDARDS CONFORMANCE"
404 As of GNU xargs version 4.2.9, the default behaviour of
406 is not to have a logical end-of-file marker. POSIX (IEEE Std 1003.1,
407 2004 Edition) allows this.
409 The \-l and \-i options appear in the 1997 version of the POSIX
410 standard, but do not appear in the 2004 version of the standard.
411 Therefore you should use \-L and \-I instead, respectively.
413 The POSIX standard allows implementations to have a limit on the size
416 functions. This limit could be as low as 4096 bytes including the size of the
417 environment. For scripts to be portable, they must not rely on a
418 larger value. However, I know of no implementation whose actual limit
421 option can be used to discover the actual limits in force on the
426 \fBfind\fP(1), \fBlocate\fP(1), \fBlocatedb\fP(5), \fBupdatedb\fP(1),
427 \fBfork\fP(2), \fBexecvp\fP(3),
428 \fBFinding Files\fP (on-line in Info, or printed)
432 option is incompatible with the
434 option, but perhaps should not be.
436 It is not possible for
438 to be used securely, since there will always be a time gap between the
439 production of the list of input files and their use in the commands
442 issues. If other users have access to the system, they can manipulate
443 the filesystem during this time window to force the action of the
446 runs to apply to files that you didn't intend. For a more detailed
447 discussion of this and related problems, please refer to the
448 ``Security Considerations'' chapter in the findutils Texinfo
453 can often be used as a more secure alternative.
457 option, each line read from the input is buffered
458 internally. This means that there is an upper limit on the length
461 will accept when used with the
463 option. To work around this
464 limitation, you can use the
466 option to increase the amount of
469 uses, and you can also use an extra invocation of
471 to ensure that very long lines do not occur.
474 .B somecommand | xargs \-s 50000 echo | xargs \-I '{}' \-s 100000 rm '{}'
476 Here, the first invocation of
478 has no input line length limit
479 because it doesn't use the
481 option. The second invocation of
483 does have such a limit, but we have ensured that the it never encounters
484 a line which is longer than it can handle. This is not an ideal
485 solution. Instead, the
487 option should not impose a line length
488 limit, which is why this discussion appears in the BUGS section.
489 The problem doesn't occur with the output of
491 because it emits just one filename per line.
493 The best way to report a bug is to use the form at
494 http://savannah.gnu.org/bugs/?group=findutils.
495 The reason for this is that you will then be able to track progress in
496 fixing the problem. Other comments about \fBxargs\fP(1) and about
497 the findutils package in general can be sent to the
499 mailing list. To join the list, send email to
500 .IR bug\-findutils\-request@gnu.org .