The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 09-10-2007
ranga27 ranga27 is offline
Registered User
 

Join Date: May 2006
Posts: 63
Help Needed in Grep Command

Hi

i am using grep command to search a string in a file and i am able to find that string in it ..

but moving forward once i find the string i need to remove the 5 lines above that and to remove 2 lines below it .. Just wanted to be clear there should be no lines existing which has a string coys11

Example :

file1.txt
cat435
gggte
werwr
coys11
ewrer

when i run this script , it should delete all the lines above it and lines below it

Thanks.. Please do help me on this .. Thanks again..!!
Reply With Quote