LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grep ??? searching a file and outputting 5 lines either side... (http://www.linuxquestions.org/questions/linux-newbie-8/grep-searching-a-file-and-outputting-5-lines-either-side-835123/)

redhatuser1 09-29-2010 03:41 AM

grep ??? searching a file and outputting 5 lines either side...
 
Hi,

Anyone tell me how I can search a file and output the following.

1 - 10 lines with the search result in the middle
2 - line numbers (if possible?)

I have the grep working, simple search for a string but I would like to output the above 5 lines and the following 5 lines. Any thoughts?

redhatuser1 09-29-2010 03:42 AM

Solution

-A for trailing lines
-B for leading lines
-n for Line numbers

EDIT - I have solved this myself - forgive me

prayag_pjs 09-29-2010 03:45 AM

Quote:

:set nu
This is for vi editor


All times are GMT -5. The time now is 02:14 PM.