I am trying to find the size of the files on my hard drive in exact bytes, but whenever the size gets too big the number turns all weird (like 1.98329e+12). Can I stop it from doing this or convert this into exact bytes?
The command is:
ls -lR | grep -v '^d' | awk '{total += $5} END {print "Total:", total}'
Picture of exact bytes:
Picture of weird number:
- The cut-off point before it stops showing exact bytes seems to be around 500gb
- The command
du -sb
properly shows exact bytes no matter how big the directory is. - I have tried Ubuntu Gnome 15.10 64bit (Japanese and English) and Linux Mint 17.3 Cinnamon 64bit (Japanese)
- My drives are
ntfs
so I tried formatting one as ext4 and copying my files over. The results are same as ntfs.
ls
but clearly the problem is with the way awk displays the final result. The answer by @kos shows how to correct this.AWK
merely operates on the text.ls
on the other hand is the one giving output toawk
, and that data can be incorrect in a lot of ways. For examplels -l /dev/sda
will not show you the disk usage of sda as many people think.ls
should be used for only listing stuff, nothing more. OP's purpose is to find total disk size of all the files.