1

入力ファイルは

<section_begin>  mxsqlc


*** WARNING[13052] Cursor C is not fetched.
<section_end>
<section_begin>  b2.lst
*


*** WARNING[13052] Cursor C is not fetched.

0 errors, 1 warnings in SQL C file "b2.ppp".
<section_end>
<section_begin>  b2s0
SQLCODE=0
SQLSTATE=00000
a=10, b=abc, c=20
SQLCODE=0
SQLSTATE=00000
a=10, b=abc      , c=10, d=xyz      
<section_end>

以下の行のない出力を期待しています。

<section_end>
<section_begin>  b2s0

私のコードは

perl -ne 'print unless /^\<section_end\>(\s*|.*lst)?\s*$/' b2exp

すべての<section_end>行を削除し、この行は削除しません<section_begin> *.lst

4

2 に答える 2

2

複雑にしないでおく

perl -ne 'print unless /^\<section_/' b2exp

もう少し複雑

perl -ne 'print unless /^\<section_(end|begin)\>/' b2exp

ああ、あなたの質問は明確ではありません。(私には、おそらくそれは本当です)

<section_begin> tagname 「最初と最後に でマークされたセクションがいくつかあります。例</section_end>では、特定のタグ名を持つセクションを除外したいbs20です。他のすべての行を保持したい」

perl -ne 'BEGIN {$p=1}  $p=0 if /section_begin.*b2s0/; print if $p; $p=1 if /<section_end>/;' ex.txt
于 2013-10-07T08:18:11.373 に答える