I have a file which is having following content:
zdk aaa b12 cdn dke kdn
aaa b12 cdn
zdk aaa b12 cdn dke
I could use below commands to achieve:
grep -a aaa -A2 file # Output 1 grep -a aaa -A4 file # Output 2
But in the file I don't know what is the exact occurrence (position) of end string pattern (file is having 20000 rows)
How can I achieve this?