grep for a few lines

September 15th, 2006 mysurface Posted in grep, Text Manipulation | Hits: 9901 | 1 Comment »

One of the useful option for grep, when you find the keyword you are searching, instead of return a particular line that contains the keyword, it allows you to specified how many lines to return by specified -A option.

Let say I want to return 5 lines when i found “main” at hello.c.

grep -A 5 main hello.c

One Response to “grep for a few lines”

  1. Usually I do not post on blogs, but I want to say that this write-up very forced me to do so! Thanks, extremely nice article.

Leave a Reply