-1

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.

sadboy
  • 49

1 Answers1

0
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 }'
f35
  • 271
  • 2
    parsing the output of 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