Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Parsing 使用或在多行sed替换中_Parsing_Shell_Sed_Multiline - Fatal编程技术网

Parsing 使用或在多行sed替换中

Parsing 使用或在多行sed替换中,parsing,shell,sed,multiline,Parsing,Shell,Sed,Multiline,我对sed中一个看似简单的部分感到困惑——or语句。我编写了以下sed,它解析事件文件,其中包含封装在事件标记之间的多个事件,然后在每行上打印每个事件的输出: machinename:~$ sed -n "/<event/,/<\/event>/ {/<result/{s/.*result value=\" \(.*\)\"\/>.*/\1/g; p}; /<sender/ {s/.*phoneNo=\"\(.*\)\" country.*/\1/g; p}}

我对sed中一个看似简单的部分感到困惑——or语句。我编写了以下sed,它解析事件文件,其中包含封装在事件标记之间的多个事件,然后在每行上打印每个事件的输出:

machinename:~$ sed -n "/<event/,/<\/event>/ {/<result/{s/.*result value=\" \(.*\)\"\/>.*/\1/g; p}; /<sender/ {s/.*phoneNo=\"\(.*\)\" country.*/\1/g; p}}" xmlEventLog_2010-02-05T16:40:55.xml | sed '/Allowed/{N;s/\n/ /;}'
Allowed +989350000100
Allowed +989350000209
Allowed +989350000002
Allowed +989350000002
Allowed +989350000100
Allowed +989350000209
Allowed +989350000002
Allowed +989350000002
machinename:~$
machinename:~$sed-n”/您想写什么

sed'/\(允许\ \阻止\ \修改\)/{N;s/\N/}

:)

machinename:~$ sed -n "/<event/,/<\/event>/{/<result/{s/.*result value=\"\(.*\)\"\/>.*/\1/g; p}; /<sender/ {s/.*phoneNo=\"\(.*\)\" country.*/\1/g; p}}" xmlEventLog_2010-02-05T16:40:55.xml | sed '/(Allowed|Blocked|Modified)/{N;s/\n/ /;}'
Allowed
+989350000100
Allowed
+989350000209
Allowed
+989350000002
Allowed
+989350000002
Allowed
+989350000100
Allowed
+989350000209
Allowed
+989350000002
Allowed
+989350000002
machinename:~$