LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 08-21-2009, 09:28 PM   #1
mark_alfred
Senior Member
 
Registered: Jul 2003
Location: Toronto, Ontario, Canada
Distribution: Ubuntu Linux
Posts: 1,073

Rep: Reputation: 103Reputation: 103
looking for a way to list files sorted by size


Hello. I am looking for a way to list files sorted by size, for all files on the computer. I tried with ls, but, while I could sort them according to size, they were also organised by directory. I'd like to simply have one list of all files that is sorted by size, and not grouped by directory.
 
Old 08-21-2009, 09:54 PM   #2
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
This works on Fedora, but ls may differ by distro:

Code:
find / -type f -exec ls -l {} \; | sort -nr -k5
You may also want to avoid /proc, /dev, etc. "man find" should help.

HTH

Forrest

p.s. when I say this works, I didn't try with /, I tried from my home directory and used "." instead of "/".

Last edited by forrestt; 08-21-2009 at 09:55 PM. Reason: added p.s.
 
Old 08-22-2009, 12:06 AM   #3
JulianTosh
Member
 
Registered: Sep 2007
Location: Las Vegas, NV
Distribution: Fedora / CentOS
Posts: 674
Blog Entries: 3

Rep: Reputation: 90
du -ba | sort -rn | less
 
Old 08-22-2009, 04:25 AM   #4
mark_alfred
Senior Member
 
Registered: Jul 2003
Location: Toronto, Ontario, Canada
Distribution: Ubuntu Linux
Posts: 1,073

Original Poster
Rep: Reputation: 103Reputation: 103
Excellent. Both methods work well.
 
Old 08-22-2009, 10:20 AM   #5
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Just remember, the du method will also include directories who's total will equal the size of all the files in the directory including sub-directories.

Forrest
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create a list of files and folders (name and size only) rastiazul Linux - General 16 11-04-2008 04:14 PM
concatenate files sorted by date docaia Programming 5 08-16-2008 09:32 PM
Shell script to build a list of karaoke music files sorted by artist and title! imix40 Linux - Newbie 4 08-13-2008 08:10 PM
Howto? List all files in all directories ordered by size? rusty_turkey Linux - Newbie 2 06-17-2008 08:55 PM
How do I produce sorted list of files in current directory over a certain size? bangback Linux - Newbie 3 10-25-2006 01:11 AM


All times are GMT -5. The time now is 08:59 PM.

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