Are `-L1` and `-n 1` the same for `xargs`?
From the manual:
-L max-lines
Use at most max-lines nonblank input lines per command line. Trailing blanks cause an input line to be logically continued on the next input line. Implies -x.-n max-args
Use at most max-args arguments per command line. Fewer than max-args arguments will be used if the size (see the -s option) is exceeded, unless the -x option is given, in which case xargs will exit.-d delim
Input items are terminated by the specified character. [...]
Based on this and my understanding, in your case -L1
and -n1
are made equivalent both by the argument 1
passed and the delimiter changed from blank space to \n
(newline) by the argument -d
For example, without the -d
argument if you were to have a blank space in your locate output, then this line would be splitted into two arguments and hence 2 different use of rm with -n1
, while it would still be treated as one argument and only one command with -L1
It appears that the difference, based on reading the manual, is that -L
filters for nonblank lines, while -n
does not. Presuming that locate
will never output a line containing only whitespace, they should be functionally identical in this use-case.
The option -L is an XSI extension and is not required to be present on embedded systems.
The -n option is part of the basic standard and always works.
See the standard as a reference: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/xargs.html
Note that some implementation may also switch the behavior for lines that end in spaces while others may concatenate a line ending in space regardless of whether the -L option has been specified.