If I have files a
, b
and c
in a directory on a Linux machine. How can I get the total number of bytes of these 3 files in a way that does not depend on how e.g. ls
shows the information? I mean I am interested in a way that is not error prone
Update
1) I am interested in binary files not ascii files
2) It would be ideal to be a portable solution e.g. GNU linux or Mac working
Best Answer
Use
du
with the-c
(print total) and-b
(bytes) options:Now, run
du
:And if you just want the total size in a variable: