You can’t, for a number of reasons.
The first is that a directory’s size grows, but it doesn’t shrink (on most file systems anyway). Try this:
mkdir testdir && cd testdir
touch {1..100000}
rm {1..100000}
ls -ld ../testdir
This will produce a fairly large directory (nothing like yours admittedly, but that’s irrelevant here) containing no files...
The second is that in most cases, file records inside a directory entry are variable in length, depending on the file’s name. See for example the ext4 disk layout.
The third is that the directory might not even be linear, which complicates matters further.
The fourth is that a directory’s size is a multiple of the block size, so a directory with one file and a directory with twenty will usually have the same size.
ls -ald
is equivalent tols -ld
— thed
option makes thea
option irrelevant. – Scott - Слава Україні Aug 08 '17 at 18:52man ls
-a, --all: do not ignore entries starting with . -d, --directory: list directory entries instead of contents, and do not dereference symbolic links – jrw32982 Aug 10 '17 at 02:32-d
means list directory entries instead of contents, or, somewhat more clearly, “list directories themselves, not their contents” (seels(1)
here) — in short, *don’t list directory contents, further discussed here and here.-a
and-A
affect which* entries are listed (and which are not) when listing a directory’s contents — which doesn’t happen when you specify-d
, so-a
and-A
are moot. – Scott - Слава Україні Aug 10 '17 at 02:53ls -ald
came from, but you're right that when you use-d
it doesn't seem to help (or hurt) to use-a
. – jrw32982 Aug 10 '17 at 17:32