Modified documentation of "-s" option to take into account the fix for
[findutils.git] / xargs / xargs.1
blobb598b238eb8851b7739f18067646cc2464ee59ee
1 .TH XARGS 1L \" -*- nroff -*-
2 .SH NAME
3 xargs \- build and execute command lines from standard input
4 .SH SYNOPSIS
5 .B xargs
6 [\-0prtx] [\-e[eof-str]] [\-i[replace-str]] [\-l[max-lines]]
7 [\-n max-args] [\-s max-chars] [\-P max-procs] [\-\-null] [\-\-eof[=eof-str]]
8 [\-\-replace[=replace-str]] [\-\-max-lines[=max-lines]] [\-\-interactive]
9 [\-\-max-chars=max-chars] [\-\-verbose] [\-\-exit] [\-\-max-procs=max-procs]
10 [\-\-max-args=max-args] [\-\-no-run-if-empty] [\-\-version] [\-\-help]
11 [command [initial-arguments]]
12 .SH DESCRIPTION
13 This manual page
14 documents the GNU version of
15 .BR xargs .
16 .B xargs
17 reads arguments from the standard input, delimited by blanks (which can be
18 protected with double or single quotes or a backslash) or newlines,
19 and executes the
20 .I command
21 (default is /bin/echo) one or more times with any
22 .I initial-arguments
23 followed by arguments read from standard input.  Blank lines on the
24 standard input are ignored.
26 Because Unix filenames can contain blanks and newlines, this default
27 behaviour is often problematic; filenames containing blanks
28 and/or newlines are incorrectly processed by 
29 .BR xargs .
30 In these situations it is better to use the `-0' option, which
31 prevents such problems.   When using this option you will need to 
32 ensure that the program which produces the input for 
33 .B xargs 
34 also uses a null character as a separator.  If that program is 
35 GNU 
36 .B find
37 for example, the `-print0' option does this for you.
39 If any invocation of the command exits with a status of 255, 
40 .B xargs 
41 will stop immediately without reading any firther input.  An error
42 message is issued on stderr when this happens.
43 .SS OPTIONS
44 .TP
45 .I "\-\-null, \-0"
46 Input filenames are terminated by a null character instead of by
47 whitespace, and the quotes and backslash are not special (every
48 character is taken literally).  Disables the end of file string, which
49 is treated like any other argument.  Useful when arguments might
50 contain white space, quote marks, or backslashes.  The GNU find
51 \-print0 option produces input suitable for this mode.
52 .TP
53 .I "\-\-eof[=eof-str], \-e[eof-str]"
54 Set the end of file string to \fIeof-str\fR.  If the end of file
55 string occurs as a line of input, the rest of the input is ignored.
56 If \fIeof-str\fR is omitted, there is no end of file string.  If this
57 option is not given, the end of file string defaults to "_".
58 .TP
59 .I "\-\-help"
60 Print a summary of the options to
61 .B xargs
62 and exit.
63 .TP
64 .I "\-\-replace[=replace-str], \-i[replace-str]"
65 Replace occurences of \fIreplace-str\fR in the initial arguments with
66 names read from standard input.
67 Also, unquoted blanks do not terminate arguments.
68 If \fIreplace-str\fR is omitted, it
69 defaults to "{}" (like for `find \-exec').  Implies \fI\-x\fP and
70 \fI\-l 1\fP.
71 .TP
72 .I "\-\-max-lines[=max-lines], -l[max-lines]"
73 Use at most \fImax-lines\fR nonblank input lines per command line;
74 \fImax-lines\fR defaults to 1 if omitted.  Trailing blanks cause an
75 input line to be logically continued on the next input line.  Implies
76 \fI\-x\fR.
77 .TP
78 .I "\-\-max-args=max-args, \-n max-args"
79 Use at most \fImax-args\fR arguments per command line.  Fewer than
80 \fImax-args\fR arguments will be used if the size (see the \-s option)
81 is exceeded, unless the \-x option is given, in which case \fBxargs\fR
82 will exit.
83 .TP
84 .I "\-\-interactive, \-p"
85 Prompt the user about whether to run each command line and read a line
86 from the terminal.  Only run the command line if the response starts
87 with `y' or `Y'.  Implies \fI\-t\fR.
88 .TP
89 .I "\-\-no-run-if-empty, \-r"
90 If the standard input does not contain any nonblanks, do not run the
91 command.  Normally, the command is run once even if there is no input.
92 .TP
93 .I "\-\-max-chars=max-chars, \-s max-chars"
94 Use at most \fImax-chars\fR characters per command line, including the
95 command and initial arguments and the terminating nulls at the ends of
96 the argument strings.  The default is 20480 characters, not including
97 the size of the environment variables (which are provided for
98 separately so that it doesn't matter if your environment variables
99 take up more than 20480 bytes).
101 .I "\-\-verbose, \-t"
102 Print the command line on the standard error output before executing
105 .I "\-\-version"
106 Print the version number of
107 .B xargs
108 and exit.
110 .I "\-\-exit, \-x"
111 Exit if the size (see the \fI\-s\fR option) is exceeded.
113 .I "\-\-max-procs=max-procs, \-P max-procs"
114 Run up to \fImax-procs\fR processes at a time; the default is 1.  If
115 \fImax-procs\fR is 0, \fBxargs\fR will run as many processes as
116 possible at a time.  Use the \fI\-n\fR option with \fI\-P\fR;
117 otherwise chances are that only one exec will be done.
118 .SH "EXAMPLES"
120 .B find /tmp -name core -type f -print | xargs /bin/rm -f
123 Find files named 
124 .B core
125 in or below the directory 
126 .B /tmp 
127 and delete them.  Note that this will work incorrectly if there are 
128 any filenames containing newlines or spaces.
130 .B find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
133 Find files named 
134 .B core
135 in or below the directory 
136 .B /tmp 
137 and delete them, processing filenames in such a way that file or 
138 directory names containing spaces or newlines are correctly handled.
141 .B cut -d: -f1 < /etc/passwd | sort | xargs echo
144 Generates a compact listing of all the users on the system.
145 .SH "EXIT STATUS"
146 .B xargs
147 exits with the following status:
149 0 if it succeeds
150 123 if any invocation of the command exited with status 1-125
151 124 if the command exited with status 255
152 125 if the command is killed by a signal
153 126 if the command cannot be run
154 127 if the command is not found
155 1 if some other error occurred.
157 .SH "SEE ALSO"
158 \fBfind\fP(1L), \fBlocate\fP(1L), \fBlocatedb\fP(5L), \fBupdatedb\fP(1)
159 \fBFinding Files\fP (on-line in Info, or printed)
160 .SH "BUGS"
162 Some options exist in POSIX but are not yet implemented.
164 The best way to report a bug is to use the form at
165 http://savannah.gnu.org/bugs/?group=findutils.  
166 The reason for this is that you will then be able to track progress in
167 fixing the problem.   Other comments about \fBxargs\fP(1L) and about
168 the findutils package in general can be sent to the 
169 .I bug-findutils
170 mailing list.  To join the list, send email to 
171 .IR bug-findutils-request@gnu.org .