grep and display the below lines in file
I have a list a file, I want to grep a word and display rest lines after the match was found.
for example :
So, if I grep "1.234", I want display the rest after this as :
you can try the -A option followed by the number of lines to display after the match
I think there are more ways to achieve this with awk or sed
grep -A 2 1.234
Grep, im not so sure of.
But with sed.
Please use [code][/code] tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.
I believe the A,B,C options in grep are only able to print fixed numbers of lines, and can't be told to go "to the end".
fukawi1's sed command is probably the best way to go. I'll also add that a gnu extension lets you use "0" instead of "1", to ensure that the address range works when the pattern appears on the first line.
Here are a few useful sed references.
The sed faq is especially helpful for cases like this.
|All times are GMT -5. The time now is 06:54 PM.|