4
6

More than 5 years have passed since last update.

awk > コンマとコロン区切りのデータを分割する > awk -F "[,:]" '{print $2, $3}' test.dat

Last updated at Posted at 2015-03-03

動作確認

CentOS 6.5
test.dat
1,2,3,4
2,2;3,4
3:2,3,4

というファイルがあるとする。この2列目と3列目を取りたい時は以下のようにする。

$awk -F "[,:]" '{print $2, $3}' test.dat
2 3
2 3
2 3

"[,:]"は複数の区切り文字を指定しており、","":"を区切りと認識する。

4
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
4
6