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.
August 30th, 2013 on 02:36
very helpful, thanks alot
June 19th, 2014 on 03:34
Thanks!