Why does xargs -L give the correct format, but xargs -n does not?

Consider the following:

$ echo index.html* | xargs -L 1 ls -l
-rw-r--r-- 1 zeki zeki  17198 2011-05-03 23:18 index.html
-rw-r--r-- 1 zeki zeki  17198 2011-05-03 23:20 index.html.1
-rw-r--r-- 1 zeki zeki  17198 2011-05-03 23:21 index.html.2
-rw-r--r-- 1 zeki zeki 146589 2011-05-05 12:29 index.html.3
$ echo index.html* | xargs -n 1 ls -l
-rw-r--r-- 1 zeki zeki 17198 2011-05-03 23:18 index.html
-rw-r--r-- 1 zeki zeki 17198 2011-05-03 23:20 index.html.1
-rw-r--r-- 1 zeki zeki 17198 2011-05-03 23:21 index.html.2
-rw-r--r-- 1 zeki zeki 146589 2011-05-05 12:29 index.html.3

Why does the -n option give incorrect formatting? Just in case, I use bash under Ubuntu. Thank.

+5
source share
2 answers

-Lbreaks into lines; echoIt doesn’t separate its output by line, but by space, therefore it executes one ls -land formats all columns as a group.

-n ; -L -0 (, ), ls -l run, .

+12

POSIX :

-L

number . , . , , <blank>; <blank> .

-n

, . ( ).

( ). echo * , xargs -L 1 ls ls .

( , ls -l index.html*, , , .)

+3

All Articles