Hello,
I'm trying to make a shell script to skip comments from an XML file, but with the code below only deletes comments that are in one line.
Can you tell me what can be added here?
Code:
nawk '
{
if($0 !~/<!--/) { a=0 }
if($0 ~/<!--/ && $0 ~/-->/) {a=1}
if($0 ~/<!--/) {a=1}
if (a == 1) {next}
if ($0 ~/-->/) {next}
if (a == 0) {print $a}
}
' ff
The file is:
Code:
this is a file
<!-- lalala lalaa 1223
zzz
-->
begin here
important text here
<!-- 34543645 dsgs 1223
-->
important text here2
And the output is:
Code:
this is a file
zzz
begin here
important text here
important text here2
As you can see the line "zzz" should not be printed.
Thanks