Output whole line once for each unique value of a column (Bash)

后端 未结 4 1559
故里飘歌
故里飘歌 2020-12-17 22:06

This must surely be a trivial task with awk or otherwise, but it\'s left me scratching my head this morning. I have a file with a format similar to this:

<
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-17 22:50

    I would use Perl for this:

    perl -nae 'print unless exists $seen{$F[1]}; undef $seen{$F[1]}' < input.txt
    

    The n switch works line by line with the input, the a switch splits the line into the @F array.

提交回复
热议问题