ls -l will show all file and folder in detail information. but folder size is not correct(alwasy show 4.0k).
So how to show file/folder as ls -l
format besides folder with correct size. Thanks!
ls -l format:
drwxr-xr-x 9 jerry jerry XXX.0K Mar 3 14:34 Flask-0.10.1
-rw-rw-r-- 1 jerry jerry 532K Mar 3 14:25 Flask-0.10.1.tar.gz
drwxrwxr-x 10 jerry jerry XXXK Feb 8 15:41 leveldb1.15
quoting @izx
So the minimum size displayed can be only
4.0k
Try:
This prints the disk usage for each folder to a depth of 1, which is the equivalent of ls -al
Made a script similar to this (replicating some
ls
options) before, madedu
change and should work hereWill obviously be quite a bit slower than regular
ls
, since it has to calculate size.Example output
You can use the
-printf
option offind
to get most of the info - see the man page for more info. The easiest way I know to find the size of a directory including everything inside it is withdu -s
, so you will have to print/paste these values together. eg:Sample output:
So: permission/owner/date/name/size in bytes
I'm not quite sure if this is what you are looking for - but from
man ls
:EDIT: Based on your comment I would set up an alias to get an output which gives you the desired data but breaks the typical format of
ls
- e.g.:Result:
I do not know of any way to achieve your goal with
ls
only.For sure there's a better way, but this works for me: