How to display the line number of file while searching for a pattern

awk 'BEGIN{IGNORECASE=1} /error|warning|exception/  { ++x } END { print x }' filename
 The above command returning the number of times the pattern present in the file.  But I want the the line number as well. please help me out

Hi arukuku,

But there could be many line numbers. How do you want the output?

Regards,
Birei

The builtin awk variable NR stands for the line no...so knowing that you can add some code to your awk script to print out NR whenver the desired pattern is matched...

Birei , I want the line number for which the pattern matches.
Sham rock, Ya tryin to do that. But not able to do it . I want to do it in awk only

where it says ++x you can also print the line number (NR)

grep -n 'pattern'

Good thought, but we would need ERE for different choices and we need to ignore case, so grep -Ein 'pattern' would be the ticket, but then we would not get the total number of matches, although we could run it through wc -l separately in case we'd really need to know..