需求如题:
文本实例dalu.log:
c5cc1dc6b2d83cd913b4b150a 67519
a13e9d85c558f7b0f6d05fe03 67519
31bfbcaeb21af1a5c104ad762 32276
c5cc1dc6b2d83cd913b4b150a 67519
8f38634388c793a77fdeef91e 88888
c5cc1dc6b2d83cd913b4b150a 67519
8f38634388c793a77fdeef91e 67519
8f38634388c793a77fdeef91e 88888
ba7994ab1e1a17e0c512c914e 55559
nl dalu.log | sort -nr | cut -f2 | sort -t ' ' -k 2 -u
31bfbcaeb21af1a5c104ad762 32276
ba7994ab1e1a17e0c512c914e 55559
8f38634388c793a77fdeef91e 67519
8f38634388c793a77fdeef91e 88888
解释:
nl dalu.log :加入编号
sort -nr :倒叙
cut -f2 :去掉编号
sort -t ’ ’ -k 2 -u:按空格分隔后,按第二列的内容去重