我有格式如下的资料
Client dropped connection 52013
Compression error 2
Deactivating 1242
FTP error 0
FTPS not configured 174
Flow expired (sweeper) 2164495
我需要把资料重组成这样的格式
sometext,type=Client_dropped_connection value=52013
sometext,type=Compression_error value=2
...
...
...
由于前面文字的部份每列字段数非固定,透过awk拆解使用下列的语法
awk 'BEGIN{FS = "[ \t]+" ;ORS = "_"} {for(i=1;i<NF;i++) {print $i,"\n"}}'
原本预期能够将前面的文字重组成类似这样 -> Client_dropped_connection
结果输出结果却是像下面这样
Client
_dropped
_connection
_Compression
_error
_Deactivating
_FTP
_error
_FTPS
_not
_configured
_Flow
_expired
_(sweeper)
不加 "\n" {print $i,"\n"} 输出的结果却是所有的字都在同一行
试过几种方法都得不出我想要的结果
不知道是语法哪边出错?