LoginSignup
6
6

More than 5 years have passed since last update.

awkコマンドメモ

Posted at

awkコマンドメモ、徐々に複雑なパターンを追加していく予定。。

全ての行の1フィールド目を出力

awk '{ print $1 }'

区切り文字を","として1フィールド目を表示

 awk -F , '{print $1}'

1行目が"a"の時に1フィールド目を出力

awk '$1=="a" {print $1}'

3行目の1フィールド目を出力

awk 'NR==3 {print $1}'

3フィールド以上ある行の1フィールド目を出力

awk 'NF > 3 {print $1}' 

すべての行の最後のフィールドを出力

awk '{print $NF}'

すべての行の1フィールド目を除いて出力

 awk '{ $1=""; print }'

すべての行の1フィールド目の出現回数をカウントして降順に並び替えて出力

awk '{print $1}' | sort | uniq -c | sort -r
6
6
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
6
6