Linux 中实现去重复后仍然按照原来的顺序输出
001、一般去重复
[root@PC1 test01]# ls a.txt [root@PC1 test01]# cat a.txt ## 测试文本 c d c a b b [root@PC1 test01]# cat a.txt | sort | uniq ## 去重复后也排序了 a b c d
002、去重复后保持原来的顺序
[root@PC1 test01]# ls a.txt [root@PC1 test01]# cat a.txt ## 测试文本 c d c a b b [root@PC1 test01]# awk '!ay[$0]++' a.txt ## 去重复后保持原来的顺序 c d a b
。