LoginSignup
0
1

More than 5 years have passed since last update.

awkサンプル集

Posted at

すぐ忘れてしまうので備忘録。

こういうファイルを

date.txt
20170102,5
20170209,1
20170315,9

こうしたい

2017-01-02,5
2017-02-09,1
2017-03-15,9
cat date.txt | awk -F"," '{
  year = substr($1, 0, 4)
  month = substr($1, 5, 2)
  day = substr($1, 7, 2)
  print year "-" month "-" day "," $2
}'
0
1
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
1