Friday, October 25, 2019

Split a word with awk

 sed 's/_t/ /g' file | awk '{print substr($0,1,4),substr($0,5,2),substr($0,7,2),$2,$3,$4,$5}'

file:
20191007_t15   1.9    64
20191007_t16   6.1    86
20191007_t17   6.5    80
20191007_t18   5.8    91
20191007_t19   5.4    93
20191007_t20   4.9    87
20191007_t21   5.0    90
20191007_t22   4.3    94

result:

2019 10 07 15 1.9 64
2019 10 07 16 6.1 86
2019 10 07 17 6.5 80
2019 10 07 18 5.8 91
2019 10 07 19 5.4 93
2019 10 07 20 4.9 87
2019 10 07 21 5.0 90
2019 10 07 22 4.3 94

No comments: