Skip to content
Advertisement

Why does xargs -L yield the right format, while xargs -n doesn’t?

Consider the following:

JavaScript

Why does the -n option yield an incorrect formatting? Just in case, I’m using bash under Ubuntu. Thanks.

Advertisement

Answer

-L splits by lines; echo doesn’t separate its output by lines but by spaces, so a single ls -l is run and that formats all the columns as a group.

-n splits by parameters; in the absence of -L or -0, the separator is whitespace (possibly modified by quoting), so each filename gets its own ls -l run and there is no way for the independent runs to coordinate column widths.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement