-請問這樣的資料要如何用awk處理 - Linux

By Cara
at 2018-05-31T12:04
at 2018-05-31T12:04
Table of Contents
我有格式如下的資料
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"} 輸出的結果卻是所有的字都在同一行
試過幾種方法都得不出我想要的結果
不知道是語法哪邊出錯?
--
Tags:
Linux
All Comments

By Andy
at 2018-06-03T10:38
at 2018-06-03T10:38

By Catherine
at 2018-06-06T16:22
at 2018-06-06T16:22

By Vanessa
at 2018-06-11T12:52
at 2018-06-11T12:52

By Michael
at 2018-06-12T16:36
at 2018-06-12T16:36

By Donna
at 2018-06-14T23:29
at 2018-06-14T23:29

By Noah
at 2018-06-18T19:53
at 2018-06-18T19:53

By Ula
at 2018-06-22T15:18
at 2018-06-22T15:18

By Dorothy
at 2018-06-24T11:50
at 2018-06-24T11:50

By Zanna
at 2018-06-28T08:39
at 2018-06-28T08:39
Related Posts
我可以用linuxmint 來當server 嗎?

By Dora
at 2018-05-30T09:27
at 2018-05-30T09:27
vsftpd登入後無法離開家目錄

By Ursula
at 2018-05-29T19:16
at 2018-05-29T19:16
請問有關PPTP Server on Linux問題

By Rae
at 2018-05-29T14:04
at 2018-05-29T14:04
關於電視 EDID 的問題

By Hamiltion
at 2018-05-28T22:09
at 2018-05-28T22:09
不好意思 問一個freebsd 的問題

By William
at 2018-05-28T17:47
at 2018-05-28T17:47