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 default is 131072 characters, not including
138 the size of the environment variables (which are provided for
139 separately so that it doesn't matter if your environment variables
140 take up more than 131072 bytes). The operating system places limits
141 on the values that you can usefully specify, and if you exceed these a
142 warning message is printed and the value actually used is set to the
143 appropriate upper or lower limit.
145 .I "\-\-verbose, \-t"
146 Print the command line on the standard error output before executing
150 Print the version number of
154 .I "\-\-show\\-limits"
155 Display the limits on the command-line length which are imposed by the
158 choice of buffer size and the
160 option. Pipe the input from
163 .BR --no-run-if-empty )
169 Exit if the size (see the \fI\-s\fR option) is exceeded.
171 .I "\-\-max\-procs=max-procs, \-P max-procs"
172 Run up to \fImax-procs\fR processes at a time; the default is 1. If
173 \fImax-procs\fR is 0, \fBxargs\fR will run as many processes as
174 possible at a time. Use the \fI\-n\fR option with \fI\-P\fR;
175 otherwise chances are that only one exec will be done.
178 .B find /tmp \-name core \-type f \-print | xargs /bin/rm \-f
183 in or below the directory
185 and delete them. Note that this will work incorrectly if there are
186 any filenames containing newlines or spaces.
188 .B find /tmp \-name core \-type f \-print0 | xargs \-0 /bin/rm \-f
193 in or below the directory
195 and delete them, processing filenames in such a way that file or
196 directory names containing spaces or newlines are correctly handled.
199 .B cut \-d: \-f1 < /etc/passwd | sort | xargs echo
202 Generates a compact listing of all the users on the system.
205 exits with the following status:
208 123 if any invocation of the command exited with status 1-125
209 124 if the command exited with status 255
210 125 if the command is killed by a signal
211 126 if the command cannot be run
212 127 if the command is not found
213 1 if some other error occurred.
216 Exit codes greater than 128 are used by the shell to indicate that
217 a program died due to a fatal signal.
218 .SH "STANDARDS CONFORMANCE"
219 As of GNU xargs version 4.2.9, the default behaviour of
221 is not to have a logical end-of-file marker. POSIX (IEEE Std 1003.1,
222 2004 Edition) allows this.
224 The \-l and \-i options appear in the 1997 version of the POSIX
225 standard, but do not appear in the 2004 version of the standard.
226 Therefore you should use \-L and \-I instead, respectively.
229 \fBfind\fP(1), \fBlocate\fP(1), \fBlocatedb\fP(5), \fBupdatedb\fP(1),
230 \fBFinding Files\fP (on-line in Info, or printed)
232 The \-L option is incompatible with the \-I option, but perhaps should not be.
234 It is not possible for
236 to be used securely, since there will always be a time gap between the
237 production of the list of input files and their use in the commands
240 issues. If other users have access to the system, they can manipulate
241 the filesystem during this time window to force the action of the
244 runs to apply to files that you didn't intend. For a more detailed
245 discussion of this and related problems, please refer to the
246 ``Security Considerations'' chapter in the findutils Texinfo
247 documentation. The \-execdir option of
249 can often be used as a more secure alternative.
251 When you use the \-I option, each line read from the input is buffered
252 internally. This means that there is an upper limit on the length
255 will accept when used with the \-I option. To work around this
256 limitation, you can use the \-s option to increase the amount of
259 uses, and you can also use an extra invocation of
261 to ensure that very long lines do not occur.
264 .B somecommand | xargs \-s 50000 echo | xargs \-I '{}' \-s 100000 rm '{}'
266 Here, the first invocation of
268 has no input line length limit
269 because it doesn't use the \-i option. The second invocation of
271 does have such a limit, but we have ensured that the it never encounters
272 a line which is longer than it can handle. This is not an ideal
273 solution. Instead, the \-i option should not impose a line length
274 limit, which is why this discussion appears in the BUGS section.
275 The problem doesn't occur with the output of
277 because it emits just one filename per line.
279 The best way to report a bug is to use the form at
280 http://savannah.gnu.org/bugs/?group=findutils.
281 The reason for this is that you will then be able to track progress in
282 fixing the problem. Other comments about \fBxargs\fP(1) and about
283 the findutils package in general can be sent to the
285 mailing list. To join the list, send email to
286 .IR bug\-findutils\-request@gnu.org .