2

In the case we have some files with different sizes: for example one files smaller than 1 Mb and others bigger than 1 MB for example.

If I use ls -l --block-size=M it will show all files with less value of 1 MB with 1 MB. So it could be useful list the files with two different columns one with MB and other with KB.

I've tested ls -l --block-size=M --block-size=K but it lists the size by the last argument.

Is it possible to list multiples block sizes?

  • The --block-size option (at least in GNU ls) only scales the displayed size of files. It does not filter out files that are less in size. Can you provide example output in command line and paste it in to your question ? Which OS version are you using ? – Sergiy Kolodyazhnyy Mar 7 '17 at 18:17
  • 2
    If you are trying to list files with "automatically" scaled , to show one file with k and another with M, then use ls -l -h. (Let me know if you want this as full answer) – Sergiy Kolodyazhnyy Mar 7 '17 at 18:19
  • 1
    OK, will post in couple minutes – Sergiy Kolodyazhnyy Mar 7 '17 at 18:56
2

To display size of files scaled to the nearest binary prefix, use -h flag ( same as --human-readable long option ):

$ ls -l -h
total 3.4M
-rwxrwxr-x 1 xieerqi xieerqi  223 3月   5 16:32 find_dir.pl*
drwxrwxr-x 3 xieerqi xieerqi 4.0K 3月   5 13:26 levelone/
-rw-rw-r-- 1 xieerqi xieerqi 3.4M 3月   7 11:57 XUf6uMr.jpg

Same information, but in powers of 10 can be displayed with --si option:

$ ls -l --si                                                                                                             
total 3.6M
-rwxrwxr-x 1 xieerqi xieerqi  223 3月   5 16:32 find_dir.pl*
drwxrwxr-x 3 xieerqi xieerqi 4.1k 3月   5 13:26 levelone/
-rw-rw-r-- 1 xieerqi xieerqi 3.6M 3月   7 11:57 XUf6uMr.jpg
| improve this answer | |
3

Try ls -lh. This shows "human readable" sizes.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.