bash - How to remove a line that match a pattern of sepific occurance? -


here delete line match <li><p><a href="anti\/recent.html"> fourth occurance

i asked here before bit different, @ time have match <ul>

at time answer:

    awk '/<ul>/ {ul++} ul == 6 { getline } 1' file 

however , can not applied <li><p><a href="anti\/recent.html">

and in other post have got answer:

awk '/<li><p><a href="anti\/recent.html">/ {a++} == 4 { getline } 1' file 

the awk seems have bug

^i^i^i^i^i^i^i^i^i<li><p><a href="anti/recent.html">4 jul 2011 - fraudulent email purporting related standard chartered bank (hong kong) limited</a></p></li>$                                       <!--<li>there no phishing attack @  moment.</li>-->$ ^i^i^i^i^i^i^i^i    </ul>$ 

for example delete </ul> although on different line?

it somehow works delete fourth item after delete many line(~40 lines) (and totally irrelevant <li><p><a href="anti\/recent.html">. reasons? thanks

awk '/<li><p><a href="anti\/recent.html">/ {a++} == 4 { getline } 1' file 

that delete line when "a" equals 4, if not match pattern. have combine ("and") conditions:

awk '/<li><p><a href="anti\/recent.html">/ && ++a == 4 {next} 1' file 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -