Linux (Ubuntu)
Linux: Get Filesize from Terminal
by admin on Aug.11, 2012, under Linux (Ubuntu)
I recently wanted to get the size of a specific file from terminal. This is useful especially when you want to use the command in one of your scripts and e.g. compare the size of one file with the size of another file.
This is how I determine the size of a file using only a single command:
stat -c %s file.txt
Another easy way of determining the size of all files in a directory would be to use ls -al but this command also returns a lot of overhead which you’d have to get rid of using other commands such as grep & cut before using the output.