1
我試圖解析字符串像這樣使用bash使用兩個現場spearators
OPS |all|1234|ip:port1|name|state|number|id|phone=123;zip=123;state=AB;city=seattle .
OPS |all|1234|ip:port2|name|state|number|id|phone=123;zip=123;state=AB;city=spokane .
我想這樣
seattle | ip port1
spokane | ip port2
我試圖用awk這個
輸出awk -F'|' '{ n = split($4,array,"|"); printf "%s, %s\n", $4, array[n] }' file.txt
但它沒有打印我想要的細節
我改變了輸入一點(OPS後有一個空格)的輸出是走出這樣 'AB;城市| 1234 ip AB; city | 1234 ip' – jigsaw
如果插入一個附加的字段分隔符,則輸出也會更改。 – Cyrus
是的,我只是改變了你的答案增加1,它的工作 – jigsaw