How do I calculate the block-filesize that all the files in a directory take? and how do I calculate the real size of all the files in the directory?
I tried some variations with df/du but they don't seem to work.
How do I calculate the block-filesize that all the files in a directory take? and how do I calculate the real size of all the files in the directory?
I tried some variations with df/du but they don't seem to work.
ls -sa | awk '{ SUM += $1 } END { print "Block size=" SUM }'
the -s
option of ls
print the allocated size of each file, in blocks
And the real size :
ls -la | awk '{ SUM += $5 } END { print "Dir size=" SUM }'
ls
is a greatly inferior method to using du
. Parsing ls
is generally a bad idea: http://unix.stackexchange.com/questions/128985/why-not-parse-ls. du
is specifically made for getting information about disk space usage/size on disk.
– Centimane
Nov 22 '16 at 19:51
du -s the-dir
? – Stéphane Chazelas Nov 22 '16 at 19:37