1 .TH XARGS 1 \" -*- nroff -*-
3 xargs \- build and execute command lines from standard input
6 [\-0prtx] [\-E eof-str] [\-e[eof-str]] [\-\-eof[=eof-str]] [\-\-null]
7 [\-d delimiter] [\-\-delimiter delimiter]
8 [\-I replace-str] [\-i[replace-str]] [\-\-replace[=replace-str]]
9 [\-l[max-lines]] [\-L max-lines] [\-\-max\-lines[=max-lines]] [\-n max-args] [\-\-max\-args=max-args]
10 [\-s max-chars] [\-\-max\-chars=max-chars] [\-P max-procs] [\-\-max\-procs=max-procs]
11 [\-\-interactive] [\-\-verbose] [\-\-exit] [\-\-no\-run\-if\-empty]
12 [\-\-arg\-file=file] [\-\-show\-limits] [\-\-version] [\-\-help]
13 [command [initial-arguments]]
16 documents the GNU version of
19 reads items from the standard input, delimited by blanks (which can be
20 protected with double or single quotes or a backslash) or newlines,
23 (default is /bin/echo) one or more times with any
25 followed by items read from standard input. Blank lines on the
26 standard input are ignored.
28 Because Unix filenames can contain blanks and newlines, this default
29 behaviour is often problematic; filenames containing blanks
30 and/or newlines are incorrectly processed by
32 In these situations it is better to use the `\-0' option, which
33 prevents such problems. When using this option you will need to
34 ensure that the program which produces the input for
36 also uses a null character as a separator. If that program is
39 for example, the `\-print0' option does this for you.
41 If any invocation of the command exits with a status of 255,
43 will stop immediately without reading any further input. An error
44 message is issued on stderr when this happens.
47 .I "\-\-arg\-file=file, \-a file"
50 instead of standard input. If you use this option, stdin remains
51 unchanged when commands are run. Otherwise, stdin is redirected
57 Input items are terminated by a null character instead of by
58 whitespace, and the quotes and backslash are not special (every
59 character is taken literally). Disables the end of file string, which
60 is treated like any other argument. Useful when input items might
61 contain white space, quote marks, or backslashes. The GNU find
62 \-print0 option produces input suitable for this mode.
64 .I "\-\-delimiter=delim, \-d delim"
65 Input items are terminated by the specified character. Quotes and
66 backslash are not special; every character in the input is taken
67 literally. Disables the end-of-file string, which is treated like any
68 other argument. This can be used when the input consists of simply
69 newline-separated items, although it is almost always better to design
70 your program to use `\-\-null' where this is possible. The specified
71 delimiter may be a single character, a C-style character escape such
74 or an octal or hexadecimal escape code. Octal and hexadecimal
75 escape codes are understood as for the
77 command. Multibyte characters are not supported.
81 Set the end of file string to \fIeof-str\fR. If the end of file
82 string occurs as a line of input, the rest of the input is ignored.
83 If neither \-E nor \-e is used, no end of file string is used.
85 .I "\-\-eof[=eof-str], \-e[eof-str]"
86 This option is a synonym for the `\-E' option. Use `\-E' instead,
87 because it is POSIX compliant while this option is not. If
88 \fIeof-str\fR is omitted, there is no end of file string. If neither
89 \-E nor \-e is used, no end of file string is used.
92 Print a summary of the options to
97 Replace occurrences of \fIreplace-str\fR in the initial-arguments with
98 names read from standard input. Also, unquoted blanks do not
99 terminate input items; instead the separator is the newline character.
100 Implies \fI\-x\fP and \fI\-L 1\fP.
102 .I "\-\-replace[=replace-str], \-i[replace-str]"
103 This option is a synonym for \-I\fIreplace-str\fR if \fIreplace-str\fR
104 is specified, and for \-I{} otherwise. This option is deprecated; use
108 Use at most \fImax-lines\fR nonblank input lines per command line.
109 Trailing blanks cause an input line to be logically continued on the
110 next input line. Implies \fI\-x\fR.
112 .I "\-\-max-lines[=max-lines], \-l[max-lines]"
113 Synonym for the \-L option. Unlike \-L, the \fImax-lines\fR argument
114 is optional. If \fImax-args\fR is not specified, it defaults to one.
115 The \-l option is deprecated since the POSIX standard specifies \-L
118 .I "\-\-max\-args=max-args, \-n max-args"
119 Use at most \fImax-args\fR arguments per command line. Fewer than
120 \fImax-args\fR arguments will be used if the size (see the \-s option)
121 is exceeded, unless the \-x option is given, in which case \fBxargs\fR
124 .I "\-\-interactive, \-p"
125 Prompt the user about whether to run each command line and read a line
126 from the terminal. Only run the command line if the response starts
127 with `y' or `Y'. Implies \fI\-t\fR.
129 .I "\-\-no\-run\-if\-empty, \-r"
130 If the standard input does not contain any nonblanks, do not run the
131 command. Normally, the command is run once even if there is no input.
132 This option is a GNU extension.
134 .I "\-\-max\-chars=max-chars, \-s max-chars"
135 Use at most \fImax-chars\fR characters per command line, including the
136 command and initial-arguments and the terminating nulls at the ends of
137 the argument strings. The largest allowed value is system-dependent,
138 and is calculated as the argument length limit for exec, less the size
139 of your environment, less 2048 bytes of headroom. If this value is
140 more than 128KiB, 128Kib is used as the default value; otherwise, the
141 default value is the maximum.
143 .I "\-\-verbose, \-t"
144 Print the command line on the standard error output before executing
148 Print the version number of
152 .I "\-\-show\\-limits"
153 Display the limits on the command-line length which are imposed by the
156 choice of buffer size and the
158 option. Pipe the input from
161 .BR --no-run-if-empty )
167 Exit if the size (see the \fI\-s\fR option) is exceeded.
169 .I "\-\-max\-procs=max-procs, \-P max-procs"
170 Run up to \fImax-procs\fR processes at a time; the default is 1. If
171 \fImax-procs\fR is 0, \fBxargs\fR will run as many processes as
172 possible at a time. Use the \fI\-n\fR option with \fI\-P\fR;
173 otherwise chances are that only one exec will be done.
176 .B find /tmp \-name core \-type f \-print | xargs /bin/rm \-f
181 in or below the directory
183 and delete them. Note that this will work incorrectly if there are
184 any filenames containing newlines or spaces.
186 .B find /tmp \-name core \-type f \-print0 | xargs \-0 /bin/rm \-f
191 in or below the directory
193 and delete them, processing filenames in such a way that file or
194 directory names containing spaces or newlines are correctly handled.
197 .B cut \-d: \-f1 < /etc/passwd | sort | xargs echo
200 Generates a compact listing of all the users on the system.
203 exits with the following status:
206 123 if any invocation of the command exited with status 1-125
207 124 if the command exited with status 255
208 125 if the command is killed by a signal
209 126 if the command cannot be run
210 127 if the command is not found
211 1 if some other error occurred.
214 Exit codes greater than 128 are used by the shell to indicate that
215 a program died due to a fatal signal.
216 .SH "STANDARDS CONFORMANCE"
217 As of GNU xargs version 4.2.9, the default behaviour of
219 is not to have a logical end-of-file marker. POSIX (IEEE Std 1003.1,
220 2004 Edition) allows this.
222 The \-l and \-i options appear in the 1997 version of the POSIX
223 standard, but do not appear in the 2004 version of the standard.
224 Therefore you should use \-L and \-I instead, respectively.
226 The POSIX stadard allows implementations to have a limit on the size
229 functions. This limit could be as low as 4096 bytes including the size of the
230 environment. For scripts to be portable, they must not rely on a
231 larger value. However, I know of no implementation whose actual limit
234 option can be used to discover the actual limits in force on the
239 \fBfind\fP(1), \fBlocate\fP(1), \fBlocatedb\fP(5), \fBupdatedb\fP(1),
240 \fBFinding Files\fP (on-line in Info, or printed)
242 The \-L option is incompatible with the \-I option, but perhaps should not be.
244 It is not possible for
246 to be used securely, since there will always be a time gap between the
247 production of the list of input files and their use in the commands
250 issues. If other users have access to the system, they can manipulate
251 the filesystem during this time window to force the action of the
254 runs to apply to files that you didn't intend. For a more detailed
255 discussion of this and related problems, please refer to the
256 ``Security Considerations'' chapter in the findutils Texinfo
257 documentation. The \-execdir option of
259 can often be used as a more secure alternative.
261 When you use the \-I option, each line read from the input is buffered
262 internally. This means that there is an upper limit on the length
265 will accept when used with the \-I option. To work around this
266 limitation, you can use the \-s option to increase the amount of
269 uses, and you can also use an extra invocation of
271 to ensure that very long lines do not occur.
274 .B somecommand | xargs \-s 50000 echo | xargs \-I '{}' \-s 100000 rm '{}'
276 Here, the first invocation of
278 has no input line length limit
279 because it doesn't use the \-i option. The second invocation of
281 does have such a limit, but we have ensured that the it never encounters
282 a line which is longer than it can handle. This is not an ideal
283 solution. Instead, the \-i option should not impose a line length
284 limit, which is why this discussion appears in the BUGS section.
285 The problem doesn't occur with the output of
287 because it emits just one filename per line.
289 The best way to report a bug is to use the form at
290 http://savannah.gnu.org/bugs/?group=findutils.
291 The reason for this is that you will then be able to track progress in
292 fixing the problem. Other comments about \fBxargs\fP(1) and about
293 the findutils package in general can be sent to the
295 mailing list. To join the list, send email to
296 .IR bug\-findutils\-request@gnu.org .