LoginSignup
33
33

More than 5 years have passed since last update.

awkでカンマ区切りのデータを指定した列だけカンマ区切りで出力する

Last updated at Posted at 2014-11-27

変換

awkはデフォルトの入力/出力はスペースのためカンマに変更する

入力データ

import.csv
1,foo,bar

初期設定

入力:FS=","
出力:OFS=","

出力方法

2列目3列目:{print $2,$3}

コマンド

$ cat ./import.csv | awk 'BEGIN {FS=",";OFS=","} {print $2,$3}' > ./output.csv

出力データ

output.csv
foo,bar
33
33
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
33
33