LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-14-2005, 04:35 PM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 49
sort files after size


I want to find the biggest files on my root partition (exclude /boot and /home). How may I do that? Get some sort of list that is ordered by size.
 
Old 05-14-2005, 05:10 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
du -h /boot | sort -n

something like that should do the trick.. man sort for more options, details.. etc.
 
Old 05-14-2005, 05:44 PM   #3
six6
Member
 
Registered: Jun 2004
Location: In Adamantine Chains and penal Fire
Distribution: Debian Sarge & Ubuntu Breezy
Posts: 107

Rep: Reputation: 16
Dammit! Someone always beats me to the punchline! Anyway, I have another good solution:
Code:
du --exclude boot --exclude home -ahB K / 2>/dev/null\
| perl -e 'my @a; while(<>) { chomp; unless (-d (substr($_,\ 
index($_,"/")))) { push(@a,$_); }}@b = sort {$b <=> $a}\
@a; foreach (@b) { print"$_\n";}'

Of course, you can remove the '2>/dev/null' if you're root, and change the "size granularity" by changing 'K' in 'du -ahB K' to things like "M" for megabytes, "G" for gigabytes, etc.

Of course, my script removes directory sizes (which du outputs as default), and will sort top to bottom the largest files on the system. Also, as long as you use absolute paths, this script will recursively list largest files in any directory; just change "/" after '-ahB K' to '/example/dir' and remove the '--exclude' entries! Thanks perl!

Last edited by six6; 05-14-2005 at 05:49 PM.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script to sort files by extension otheralex Programming 7 08-19-2005 03:40 AM
Command line to sort files satimis Programming 6 06-28-2005 03:50 AM
How to sort files in a directory by date in KDE? Ace_Azzameen Linux - Software 7 05-24-2004 03:49 PM
How can it ell Grip where put my ripped files and sort the in the correct order MvD Linux - Software 2 10-16-2003 04:10 AM
increase point size size when printing PDF files newlin Red Hat 0 09-27-2003 08:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:17 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration