//View Tip #92
Similar Tips
» Count files by type
» Being selfish - Kick all users except you
» Get real names of current users
» List 10 biggest files in a directory
» My code is compiling


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 »


Add your comment

Comments are currently disabled
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