Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing smallest files in Linux [duplicate]

Tags:

linux

bash

shell

How can you print the 6 smallest files in /usr/bin directory for Shell?

ls /usr/bin

I know that this shows all the files that is in that directory but I just don't know to to print out the 6 smallest files.

What would be a one line command for this process on the command line for Shell?

like image 484
user10752715 Avatar asked Feb 04 '26 08:02

user10752715


1 Answers

Try this:

ls -SrqL /usr/bin | head -6

-S makes it sorted by file size

-r for reverse order

-q to print ? instead of nongraphic characters (line breaks included)

-L when showing file information for a symbolic link, this shows information for the file the link references rather than for the link itself

head Shows the 6 first lines of the previous output

like image 156
Carlos Avatar answered Feb 05 '26 23:02

Carlos