I've got this file:
aaa.bbb.ccc.ddd
aaa.bbb.eee.ccc
ggg.hhh.jjj.kkk
fff.uuu.yyy.ddd
eee.rrr.ddd.bbb
eee.rrr.www.zzz
eee.rrr.sss.nnn
eee.rrr.qqq.kkk
I want to filter it so it displays the whole line only when the first occurrence of the first two columns happens.
The expected output is:
aaa.bbb.ccc.ddd
ggg.hhh.jjj.kkk
fff.uuu.yyy.ddd
eee.rrr.ddd.bbb
So far what I could do was:
cat file |awk -F"." '{print $1"."$2}' |uniq -c
but it only shows the first first two columns and the number of repetitions.
sort -t. -k1,2 -u file
and if total characters for first two columns is same...uniq -w7 file
– Sundeep Apr 14 '17 at 15:55awk -F. '!seen[$1""$2]++' file
– steeldriver Apr 14 '17 at 18:12