Quantcast
Viewing latest article 2
Browse Latest Browse All 2

What does "-ls" do when used with "find"?

According to man find:

-ls

True; list current file in ls -dils format on standard output. The block counts are of 1K blocks, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used. See the UNUSUAL FILENAMES section for information about how unusual characters in filenames are handled.

I don't understand the ls -dils part.

man ls has "-d list directories themselves, not their contents".

Consider a folder with three .png files:

$ ls
01-default.png  02-jungle.png  03-snow.png
$ 

I get

$ find . -type f -ls
 12983011     28 -rw-rw-r--   1 dkb    dkb       25964 Mar 10 17:28 ./01-default.png
 12982994     24 -rw-rw-r--   1 dkb    dkb       21857 Mar 10 17:28 ./03-snow.png
 12983031     28 -rw-rw-r--   1 dkb    dkb       25964 Mar 10 17:28 ./02-jungle.png
$

But, if the -ls means the same as ls -dils, I should see something similar with ls -dils but all I get is

$ ls -dils
13631944 4 drwxrwxr-x 2 dkb dkb 4096 Aug 30 21:22 .
$ 

Whereas, ls -ils is more like what I get with find used with -ls:

$ ls -ils
total 80
12983011 28 -rw-rw-r-- 1 dkb dkb 25964 Mar 10 17:28 01-default.png
12983031 28 -rw-rw-r-- 1 dkb dkb 25964 Mar 10 17:28 02-jungle.png
12982994 24 -rw-rw-r-- 1 dkb dkb 21857 Mar 10 17:28 03-snow.png
$ 

So I was wondering if there's a typo in the man find page and whether ls -dils should really be ls ils in the part I quoted at the top of the question.


Viewing latest article 2
Browse Latest Browse All 2

Trending Articles