0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AWKマスターへの道のりAdvent Calendar 2019

Day 19

AWKコマンドで●回以上重複した行のみを抽出

Posted at

AWKマスターへの道のり アドベントカレンダーの19日目
https://qiita.com/advent-calendar/2019/awker

環境

$ awk -V
GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)

やりたいこと

特定の回数以上出現する行のみを抽出する。

コード

// テンプレ
$ cat target.tsv | awk -F'\t' '++a[$0]==<重複回数>'

// 例) 2回以上重複する行のみ
$ cat target.tsv | awk -F'\t' '++a[$0] == 2'

最後に

次回はちょうど●回重複した行のみの抽出を書きます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?