Linux ls to show file size in GB or MB

Today morning I was with one of my friends, and we were trying to figure something then we reached a point that he did a “ls” command to see the file details and sizes, well he used “ls -l” a very good and useful command but then I find him strugelling with calculating the file size, so I guided him with the h extension. In Linux most of the times when you are dealing with file sizes you can use h extension which stands for human readable. so what its very easy all you have to do is to add h to end of your switches.

like this:

# ls -lh

so the result will be something like this instead of showing bytes:

# ls -lh
total 4.8G
drwx------  2 root root     4.0K Dec 15 00:55 ./
drwxr-x--- 34 root hypermar 4.0K Dec 15 00:55 ../
-rw-r--r--  1 root root      12K Dec 15 00:55 horde.sql
-rw-r--r--  1 root root     1.5K Dec 15 00:55 rmar_1point8.create
-rw-r--r--  1 root root     743K Dec 15 00:55 mar_1point8.sql
-rw-r--r--  1 root root     1.5K Dec 15 00:52 ermar_magento.create
-rw-r--r--  1 root root     4.8G Dec 15 00:55 rmsar_magento.sql
-rw-r--r--  1 root root     8.5K Dec 15 00:55 rodcube.sql

Hope it’s helps you someday.

 

Incoming search terms:

  • ls size in gb
  • linux file size in gb
  • linux file size in mb
  • linux ls file size
  • ls gb
  • linux ls in gb
  • linux ls size in gb
  • ls display size in GB
  • ls -ltr linux gb
  • linux list file size in gb

Join the Conversation

4 Comments

Leave a comment

Leave a Reply