Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I show file sizes with commas when getting a directory listing with 'ls -l'?

You can do 'ls -l' to get a detailed directory listing like this:

-rw-rw-rw-  1 alice themonkeys 1159995999 2008-08-20 07:01 foo.log
-rw-rw-rw-  1 bob   bob         244251992 2008-08-20 05:30 bar.txt

But notice how you have to slide your finger along the screen to figure out the order of magnitude of those file sizes.

What's a good way to add commas to the file sizes in the directory listing, like this:

-rw-rw-rw-  1 alice themonkeys 1,159,995,999 2008-08-20 07:01 foo.log
-rw-rw-rw-  1 bob   bob          244,251,992 2008-08-20 05:30 bar.txt
like image 922
dreeves Avatar asked Jan 16 '09 08:01

dreeves


1 Answers

I just discovered that it's built-in to GNU Core Utils and works for ls and du!

ls -l --block-size="'1"
du --block-size="'1"

It works on Ubuntu but sadly doesn't on OSX. More on variants of block size here

like image 158
seq3 Avatar answered Oct 20 '22 03:10

seq3