sort uniq
sort:对行或者文本文件排序
uniq:去除重复的行常用
sort -n file.txt
sort -r file.txt
sort -M file.txt
sort -C file
sort -nC file
sort -m sorted_file1 sorted_file2
按键或者列进行排序
sort -nrk 1 data.txt
sort -nk 1, 2 file
sort -z file
uniq
uniq只能用于排过序的输入
sort unsort.txt | uniq
sort -u unsort.txt
uniq sorted.txt
sort unsorted.txt | uniq -c
sort unsorted.txt | uniq -d
sort data.txt | uniq -s 2 -w 3
uniq -z sorted.txt
使用uniq生成字符串样式
输入:ahebhaaa
输出:4a1b1e2hecho "ahebhaaa" | sed 's/[^.]/&\n/g' | sed '/^$/d' | sort | uniq -c | tr -d ' \n'