[root@localhost cc]# cat 2.txt
adc 3 5
a d a
a 3 adf
a d b
a 3 adf
去重第一列重复的行:
[root@localhost cc]# cat 2.txt |awk '!a[$1]++{print}'
adc 3 5
a d a
重复的行取最上面一行记录
去重以第一列和第二列重复的行:
[root@localhost cc]# cat 2.txt |awk '!a[$1" "$2]++{print}'
adc 3 5
a d a
a 3 adf
去除重复的行:
[root@localhost cc]# cat 2.txt |awk '!a[$0]++{print}'
adc 3 5
a d a
a 3 adf
a d b
只显示重复行:
[root@localhost cc]# cat 2.txt |awk 'a[$0]++{print}'
a 3 adf