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?

【CLI】awkコマンドの使い方

Posted at

スペースで区切られたファイルの 5 列目 を表示

awk '{print $5}' path/to/file

スペースで区切られたファイルの 「foo」 を含む行の 2 列目を表示

awk '/foo/ {print $2}' path/to/file

ファイル内の各行の最後の列を表示

awk -F ',' '{print $NF}' path/to/file

ファイルの最初の列の値を合計し、合計を表示

awk '{s+=$1}. END {print s}' path/to/file

最初の行から 3 行目までを表示

awk 'NR%3==1' path/to/file
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?