1

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.

2
  • 2
    if order is not important... sort -t. -k1,2 -u file and if total characters for first two columns is same... uniq -w7 file Commented Apr 14, 2017 at 15:55
  • 1
    awk -F. '!seen[$1""$2]++' file Commented Apr 14, 2017 at 18:12

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.