bash - grep - print next 10 lines if the line containing one word but not another in the same line -


I have a file that contains lines, such as:

  Here are some strings class = "Batch-2010" Here are some more strings here - click here & lt; About 20-30 links & gt; Here are some string class = "batch 2006" here are some more strings here - click here & lt; Approximately 20-30 links here & gt; Here are some string classes = "NA" here, some more strings click here - & lt; About 20-30 links & gt; Here are some string class = "batch-2010" here some more strings have been refused & lt; About 20-30 links & gt;  

I want to print that line in which:

class = "batch2010"

but not:

Access denied

Print the next 10 lines in the same line and then the file.

Is there any other way, in addition to writing really long and complex shell scripts?

This can be a solution:

  awk 'lines & Gt; 0 {print; --lines} / ass = "Batch 2010" / & amp; Amp; Output (not very relevant as many lines are not):  
  $$ / $ Awk '(line> gt; 0) {print; --lines} / ass = "Batch 2010" / & amp; Amp; ! Here are some strings here - class = "NA" Here are some more strings here - here are some strings class = class = "NA". Here are some strings class = "batch" "Batch2010" Some other strings are log-in here  

The reasoning is based on the addition of the part in which we have the ass = "batch2010" and "anonymous" Access denied .

Test

  $ seq 30 & gt; A $ Edge 'lines & gt; 0 {print; - lines} / 4 / & amp; Amp; ! / 14 / {line = 10} 'a 5 6 7 8 9 10 11 12 13 14 25 26 27 28 29 30  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -