Here i would like to delete the line that match with
<li><p><a href="anti\/recent.html">
with the fourth occurance
I asked here before but that is a bit different, at that time i only have to match with <ul>
at that time i get the answer:
awk '/<ul>/ {ul++} ul == 6 { getline } 1' file
However , that can not be applied to <li><p><a href="anti\/recent.html">
And 开发者_如何学Pythonin the other post i have got another answer:
awk '/<li><p><a href="anti\/recent.html">/ {a++} a == 4 { getline } 1' file
the awk seems have some bug
^I^I^I^I^I^I^I^I^I<li><p><a href="anti/recent.html">4 Jul 2011 - Fraudulent email purporting to be related to Standard Chartered Bank (Hong Kong) Limited</a></p></li>$
<!--<li>There is no phishing attack at this moment.</li>-->$
^I^I^I^I^I^I^I^I </ul>$
for example it will delete the </ul>
as well although that is on the different line?
it somehow works as it delete the fourth item but after that it delete so many line(~40 lines) (and that is totally irrelevant to <li><p><a href="anti\/recent.html">
. What are the reasons? Thanks
awk '/<li><p><a href="anti\/recent.html">/ {a++} a == 4 { getline } 1' file
That will delete any line when "a" equals 4, even if they do not match the pattern. You have to combine ("and") the conditions:
awk '/<li><p><a href="anti\/recent.html">/ && ++a == 4 {next} 1' file
精彩评论