LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to issue "ls" command start with the largest file size in a folder? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-issue-ls-command-start-with-the-largest-file-size-in-a-folder-468065/)

fjkum 07-26-2006 10:05 PM

How to issue "ls" command start with the largest file size in a folder?
 
Hi,

How do I use the command "ls" to display the largest file size in a folder?

AmphetaminePhreak 07-26-2006 10:16 PM

the most i could come up with is ls -s which gives you the size of all the files. i got this in the man pages

Code:

[matt@cpe-69-133-112-109 sounds]$ ls -s
total 80
48 turnmeon.wav    32 turnmeon.zip

man ls


AAnarchYY 07-26-2006 10:21 PM

sort by size largest first
Code:

ls -S

bartonski 07-26-2006 10:40 PM

I would be inclined to use ls -lrS, which gives a long listing, sorted by size, with the largest last in the list (and therefore not scrolled off the screen).

Matir 07-26-2006 11:58 PM

ls -sSr and ls -sS are both also useful.

konsolebox 07-27-2006 03:28 AM

hello fjkum. i guess you can also use du for that.

smallest first (recursive)
Code:

du * | sort -n
largest first (recursive)
Code:

du * | sort -nr
smallest first (not recursive)
Code:

du * -s | sort -n
largest first (not recursive)
Code:

du * -s | sort -nr
you can remove the numbers by adding '| cut -f 2'
Code:

du * -s | sort -nr | cut -f 2
by default the sizes are printed in kilobytes. add '-b' to du to print sizes in bytes.
Code:

du * -s -b | sort -nr
regards :)


All times are GMT -5. The time now is 06:36 AM.