I want


to show line after asad I do

awk '{if($1=="asad")next};1' test

get results


why is next not working? I only want to match the Maths not the rest of lines. I can do this with regex but I want it with comparison if condition also I want to save the results in a variable.

  • Post your expected output – 123 Jan 13 '16 at 14:03
  • Your Subject line says you want the line after the match but your question says "I only want to match the Maths not the rest of lines." Maths is on the line before your match. If you could clarify your question, we would be happy to help – rcjohnson Jan 13 '16 at 14:28

I think you want something like:

awk 'on{print;on=0} $1=="asad"{on=1}' test

The way you have it, the 1 at the end of the script is causing every line to print (except when next is called, which skips it)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.