beta.blog

Linux: Get Filesize from Terminal

by 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.


2 Comments for this entry

Leave a Reply

*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!