LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 08:28 PM   #1
mark_alfred
Senior Member
 
Registered: Jul 2003
Location: Toronto, Ontario, Canada
Distribution: Ubuntu Linux 16.04, Debian 10, LineageOS 14.1
Posts: 1,572

Rep: Reputation: 210Reputation: 210Reputation: 210
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, 08: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 08:55 PM. Reason: added p.s.
 
Old 08-21-2009, 11:06 PM   #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, 03:25 AM   #4
mark_alfred
Senior Member
 
Registered: Jul 2003
Location: Toronto, Ontario, Canada
Distribution: Ubuntu Linux 16.04, Debian 10, LineageOS 14.1
Posts: 1,572

Original Poster
Rep: Reputation: 210Reputation: 210Reputation: 210
Excellent. Both methods work well.
 
Old 08-22-2009, 09: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



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 03:14 PM
concatenate files sorted by date docaia Programming 5 08-16-2008 08:32 PM
Shell script to build a list of karaoke music files sorted by artist and title! imix40 Linux - Newbie 4 08-13-2008 07:10 PM
Howto? List all files in all directories ordered by size? rusty_turkey Linux - Newbie 2 06-17-2008 07:55 PM
How do I produce sorted list of files in current directory over a certain size? bangback Linux - Newbie 3 10-25-2006 12:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:52 AM.

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
Open Source Consulting | Domain Registration