How to Sort by Length of String Followed by Alphabetical Order Aug 17th, 2020 | Comments shell中,多行文本,先按照字母长度排序,相同长度再按照字母序排列; 做了很多次,隔几天就忘,让人绝望: 1 cat /tmp/xxx.txt|sort -u | awk '{print length($0), $0}' | sort -k2,2n -k1,1n -k3,3 |cut -d" " -f2-|less