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