【发布时间】:2016-11-03 15:18:55
【问题描述】:
我有一些来自 pdsh 的输出,我想将其格式化以加载到数据库中。我需要它在 3 列中,并且本质上希望模块 ID 和消息在一行中。波纹管是我的输出:
10.125.45.58,scope, Module ID = server-1
10.125.45.58,scope, Message = Correctable memory error
10.125.45.58,scope, Module ID = server-2
10.125.45.58,scope, Message = Correctable memory error
这是我需要的输出:
10.125.45.58,scope,server-1 Correctable memory error
10.125.45.58,scope,server-2 Correctable memory error
我一直在 awking 和 seding...我想不出任何想法?
这是我到目前为止所做的
cat myfile.txt | sed -e "s/:/\,scope\,/g" | grep -E '(Module ID|Message)'
谢谢。
【问题讨论】:
-
你能把
awk和sed发到现在吗? -
嘿,谢谢...我没有任何工作甚至关闭,我已经格式化了 pdsh 的 origanl 输出... # cat myfile.txt | sed -e "s/:/\,范围\,/g" | grep -E '(模块 ID|消息)'.
标签: linux bash awk sed formatting