• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

grep to list all lines after match

I'd like grep to output all lines after the first match (the matching line can also be included)

grep -A requires a numerical value of the number of lines (whereas I want all the remaining lines)

any ideas?  

tail +n  lists all lines after the nth line ..

so presumably theres a way to combine grep and tail to get all lines after the match

0
nsriram
Asked:
nsriram
  • 3
  • 2
1 Solution
 
yuzhCommented:
You can do :

tail +n`grep -n string filename | head -1 | cut -f1 -d' '| tr -d :` filename
0
 
nsriramAuthor Commented:
I found that simply giving a number that was larger than the number of lines in the file did the job..
I will try yours as well although its hard for a newbie me to fully follow. I do realize that the backtick is for commands

grep -A 1000000 string filename

 seems to work (assuming 1000000 is larger than the maxlines in the file)

0
 
yuzhCommented:
You can use:
wc -l filename
to find out the nubmer of lines in the file.
0
 
nsriramAuthor Commented:
thanks.. I also understand your solution.. maybe you can take a shot at my date question as well :-)
0
 
yuzhCommented:
>>maybe you can take a shot at my date question as well :-)

Could you please post the link to your date question, I'll give it a try.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now