您好我正在尝试操作使用nsradmin生成的报告(networker) 顺便说一下,这是一个简单的输出(大约有5000行)
name: SERVER1;
group: FIRST;
save set: "C:\\", "VSS SYSTEM FILESET:\\", "VSS OTHER:\\",
"VSS USER DATA:\\", "VSS SYSTEM SERVICES:\\",
"VSS SYSTEM BOOT:\\";
client OS type: Windows NT Server on Intel;
NetWorker version: 7.4.4.Build.634;
name: SERVER2;
group: NGDC_SO_5;
group: NGDC_SO_5;
"VSS OTHER:\\", "VSS USER DATA:\\",
"VSS SYSTEM SERVICES:\\", "VSS SYSTEM BOOT:\\",
"C:\\";
client OS type: Windows NT Server on Intel;
NetWorker version: 7.4.4.Build.634;
我想要这种格式的报告
name: SERVER1;group: NGDC_SO_5;VSS OTHER:\\", "VSS USER DATA:\\"client OS type: Windows NT Server on Intel;
name: SERVER2;group: NGDC_SO_5;VSS OTHER:\\", "VSS USER DATA:\\"client OS type: Windows NT Server on Intel;
第一行始终以NAME开头,最后一行是“空行。 不幸的是我试过但我没有成功
答案 0 :(得分:1)
使用awk
合并name
:
awk '/name/{if (x)print x;x="";}{x=(!x)?$0:x","$0;}END{print x;}' inputfile
答案 1 :(得分:0)
这是一个非常快速和肮脏的刺,看看它是否接近你正在寻找的东西
awk '
"" {print saved; saved=""; next}
{saved = saved " " $0}
END {print saved}
' filename
你可以用无数的方式改进它