1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
.Dd July 30, 2025
.Dt XARGS 1
.Os sbase
.Sh NAME
.Nm xargs
.Nd construct argument lists and execute command
.Sh SYNOPSIS
.Nm
.Op Fl 0prtx
.Op Fl E Ar eofstr
.Op Fl I Ar replstr
.Op Fl n Ar num
.Op Fl P Ar maxprocs
.Op Fl s Ar num
.Op Ar cmd Op Ar arg ...
.Sh DESCRIPTION
.Nm
reads space, tab, newline and EOF delimited strings from stdin
and executes the specified
.Ar cmd
with the strings as
.Ar arguments .
.Pp
Any arguments specified on the command line are given to the command upon
each invocation, followed by some number of the arguments read from
stdin.
The command is repeatedly executed one or more times until stdin is exhausted.
.Pp
Spaces, tabs and newlines may be embedded in arguments using single (`'')
or double (`"') quotes or backslashes ('\e').
Single quotes escape all non-single quote characters, excluding newlines, up
to the matching single quote.
Double quotes escape all non-double quote characters, excluding newlines, up
to the matching double quote.
Any single character, including newlines, may be escaped by a backslash.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl 0
Change
.Nm
to expect NUL ('\e0') characters as separators, instead of spaces
and newlines.
The quoting mechanisms described above are not performed.
.It Fl E Ar eofstr
Use
.Ar eofstr
as a logical EOF marker.
.It Fl I Ar replstr
Use
.Ar replstr
as the placeholder for the argument.
Sets the arguments count to 1 per command line.
It also implies the option x.
.It Fl n Ar num
Use at most
.Ar num
arguments per command line.
.It Fl p
Prompt mode: the user is asked whether to execute
.Ar cmd
at each invocation.
Trace mode (-t) is turned on to write the command instance to be executed,
followed by a prompt to standard error.
An affirmative response read from
.Pa /dev/tty
executes the command, otherwise it is skipped.
.It Fl P Ar maxprocs
Parallel mode: run at most maxprocs invocations of
.Ar cmd
at once.
.It Fl r
Do not run the command if there are no arguments.
Normally the command is executed at least once even if there are no arguments.
.It Fl s Ar num
Use at most
.Ar num
bytes per command line.
.It Fl t
Enable trace mode.
Write the command line to stderr before executing it.
.It Fl x
Terminate if the command line exceeds the system limit or the number of bytes
given with the
.Op Fl s
flag.
.El
.Sh EXIT STATUS
.Nm
exits with one of the following values:
.Bl -tag -width Ds
.It 0
All invocations of
.Ar cmd
returned a zero exit status.
.It 123
One or more invocations of
.Ar cmd
returned a nonzero exit status.
.It 124
.Ar cmd
exited with a 255 exit status.
.It 125
.Ar cmd
was killed or stopped by a signal.
.It 126
.Ar cmd
was found but could not be executed.
.It 127
.Ar cmd
could not be found.
.It 1
Some other error occurred.
.El
.Sh STANDARDS
POSIX.1-2013.
.Pp
The
.Op Fl r
and
.Op Fl P
flag is an extension to that specification.
|