I'm trying to match a pattern and then print out two lines after it. I'm successfully able to do it with the following code.
awk '/'202404'/{c=3}c&&c--' consolelog.log > testing.txt
I'm trying to replace the 202404
with something I can enter in the terminal. So far I have tried
echo "Enter peak value"
read peak
awk '/${peak}/{c=3}c&&c--' consolelog.log > testing.txt
But it does not work.
I don't necessarily need to use awk, grep or sed or anything will do. I just need to match a user inputted pattern and print 2 lines after it.
***UPDATE***** I was playing around with it and I got it to work. It was something I totally missed. Here's what I did.
awk 'c&&!--c;/'$peak'/{c=2}' consolelog.log > testing.txt
2404
in the string202404
) or only exact matches? To match exactly, it would be helpful to see the data. – Kusalananda Jan 02 '19 at 19:41peak value =202404
***********************
at location J512
– Vineeth Thomas Jan 02 '19 at 19:52