Printing lines after a match is found
The below command prints 4 lines after a match is found.
awk '/^Total Collection =/{c=4;next}c-->0' File
You can change the number of lines to be printed by changing the value of c in the command given.Please find the explanation below:
/^Total Collection =/{c=4;next}
The above statement says whenever a line starts with "Total Collection =" then initialize c to 4
c-->0
After that print the line if c is greater than 0 and for each and every line c-- is performed.
grep -A 4 '^Total Collection' File
ReplyDelete