The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 07-03-2009
Sumedha Sobti Sumedha Sobti is offline
Registered User
  
 

Join Date: Jul 2009
Location: India
Posts: 9
Hi,

There is a very simple way of doing this. Lets say you have a file test.txt having 'view' in some line. Say, you wish to get 5 lines above and below the line containing 'view' and output to a file say test_one.txt use the following:

grep -C 5 "view" test.txt > test_one.txt

Regards,
Sumedha