Created
October 7, 2015 02:03
-
-
Save isayev/942d950c0a4081f1275d to your computer and use it in GitHub Desktop.
sort lines in file by their length
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cat input.txt | awk '{ print length, $0 }' | sort -n -s | cut -d" " -f2- > input-sorted.txt | |
| # reverse order | |
| cat input.txt | awk '{ print length, $0 }' | sort -n -r | cut -d" " -f2- > input-sorted-rev.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment