Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-26-2006, 10:05 PM   #1
Registered: Feb 2006
Posts: 38

Rep: Reputation: 15
How to issue "ls" command start with the largest file size in a folder?


How do I use the command "ls" to display the largest file size in a folder?
Old 07-26-2006, 10:16 PM   #2
Registered: Jul 2006
Location: kinda transient right now. Utah is Home, staying in Ohio
Distribution: Mandrake 9.1/Windows XP
Posts: 46

Rep: Reputation: 15
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

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

man ls

Last edited by AmphetaminePhreak; 07-26-2006 at 10:19 PM.
Old 07-26-2006, 10:21 PM   #3
Registered: Sep 2004
Location: Carlisle, MA
Distribution: Debian 8
Posts: 419

Rep: Reputation: 30
sort by size largest first
ls -S
Old 07-26-2006, 10:40 PM   #4
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 47
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).
Old 07-26-2006, 11:58 PM   #5
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 124Reputation: 124
ls -sSr and ls -sS are both also useful.
Old 07-27-2006, 03:28 AM   #6
Senior Member
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
hello fjkum. i guess you can also use du for that.

smallest first (recursive)
du * | sort -n
largest first (recursive)
du * | sort -nr
smallest first (not recursive)
du * -s | sort -n
largest first (not recursive)
du * -s | sort -nr
you can remove the numbers by adding '| cut -f 2'
du * -s | sort -nr | cut -f 2
by default the sizes are printed in kilobytes. add '-b' to du to print sizes in bytes.
du * -s -b | sort -nr

Last edited by konsolebox; 07-27-2006 at 03:29 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
"File size limit exceeded" during copy h3xis Linux - Networking 2 06-17-2006 01:24 PM
rename file with "mv" not working for folder? Niceman2005 Linux - Newbie 2 03-13-2005 09:34 PM
The command "df -h" no show me the size of partition true! sandrobr Linux - Enterprise 7 01-03-2005 03:31 AM
Cannot "Copy To" .jpg file to wallpaper folder LeanPudLou SUSE / openSUSE 5 11-08-2004 08:24 AM
My system freezes after I issue the "modprobe ndiswrapper" command. markjc Linux - Wireless Networking 1 08-24-2004 09:47 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration