的文本文件:如何從複雜文件中的字段
$ cat filename.txt
2017-07-15 00:00:27,000 NAME: THT TYPE: S {"cp":"R3"}
2017-07-15 00:00:27,301 NAME: THT TYPE: S {"cp":"R3"}
2017-07-15 00:00:26,993 NAME: THT TYPE: M {"bl":"t","cp":"R1","scp":"T5"}.
,我嘗試的命令行:
$ cat filename.txt |awk '{print $1,$2,$4,$6,$7}'
2017-07-15 00:00:27,000 THT S {"cp":"R3"}
2017-07-15 00:00:27,301 THT S {"cp":"R3"}
2017-07-15 00:00:26,993 THT M {"bl":"t","cp":"R1","scp":"T5"}
所需的輸出:
017-07-15 00,THT,S,R3
017-07-15 00,THT,S,R3
017-07-15 00,THT,M,R1
我想我們可以使用「IF」,但我沒有任何想法用AWK使用「IF」。