//View Tip #92
Similar Tips
» iso2cd
» Sort the lines of a file by length
» Kill matching processes without unnecessary greps and extra sh p
» Random line
» Random IP addresses

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Sort a file by line length:


cat test.txt | awk '{ printf "%06d|%s\n",length($0),$0}' | sort | cut -b'8-'


View Comments »




Comments 

Add your comment

Comments are currently disabled
Stan
Since its all about awk. How about this:

cat test.txt | awk '{ printf "%06d|%s\n",length($0),$0}' | sort | awk -F"|" '{print $2}'
Posted 2010-03-11 02:34:21

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit