Sorting ls by filesize | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Sorting ls by filesize

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-04-2002
peter.herlihy peter.herlihy is offline
Registered User
 
Join Date: Nov 2001
Last Activity: 1 August 2006, 11:51 AM EDT
Location: New Zealand
Posts: 333
Thanks: 0
Thanked 0 Times in 0 Posts
Sorting ls by filesize

I saw some stuff in the search results on this - but nothing specific.....

I have a significant number of files (c. 300) which are output from a large process that I run. These are compared with a 'baselined' set of files - so I can quickly see if there are differences based on the sizes of the files.

I want to sort the directory into filesize...and not by number of lines. I need byte size to confirm differences.

I've thought about awk, wc -c, I've looked at sort -n ....and I've looked at the ls options...but I cant seem to get a combination to work for me.

ideas? And Yeah I realise I could cut the filesize from the ls and sort by that....but there must be a simpler way....

(Oh and I work with SunOS 5.6 and typically use a bash shell).
Sponsored Links
    #2  
Old 06-04-2002
manderson19 manderson19 is offline
Registered User
 
Join Date: Aug 2001
Last Activity: 23 April 2003, 11:27 PM EDT
Posts: 57
Thanks: 0
Thanked 1 Time in 1 Post
try:

ls -al | sort -rn +4

this does a reverse numerical sort by file size. hope this helps.
The Following User Says Thank You to manderson19 For This Useful Post:
Kumarvijay (05-19-2010)
Sponsored Links
    #3  
Old 06-04-2002
peter.herlihy peter.herlihy is offline
Registered User
 
Join Date: Nov 2001
Last Activity: 1 August 2006, 11:51 AM EDT
Location: New Zealand
Posts: 333
Thanks: 0
Thanked 0 Times in 0 Posts
Spot on - thanks.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
if condition for filesize rahulbahulekar Shell Programming and Scripting 7 10-13-2010 09:58 AM
getting filesize pppswing Shell Programming and Scripting 6 06-30-2008 09:22 AM
filesize infyanurag Shell Programming and Scripting 3 05-15-2008 06:00 AM
FileSize ??? Cameron Shell Programming and Scripting 3 05-28-2002 11:34 PM
filesize jmg5 Shell Programming and Scripting 2 02-13-2002 07:51 AM



All times are GMT -4. The time now is 04:31 AM.