Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting numerics (size from ls output)

Status
Not open for further replies.

MCubitt

Programmer
Mar 14, 2002
1,081
0
0
GB
I am sorting the output of an "ls" to put files in descending size:

find / -size +81920 -exec ls -al {} \; | sort -r -k 5 > /large.txt

However, the sort on field 5 (-k 5) ignores leading spaces (of course) so you get:

90
600
31
100

Is there a way to get leading zeros in the ls output so we get:

600
100
090
031

Thanks


There's no need for sarcastic replies, we've not all been this sad for that long!
 
Should try something with awk and printf format
 
Post Scriptum.
USE sort -nr (n flag means numerical comparison)
 
sbix, thanks - worked a treat!


There's no need for sarcastic replies, we've not all been this sad for that long!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top