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 -->
  #5 (permalink)  
Old 09-10-2007
fazliturk fazliturk is offline
Registered User
 

Join Date: Aug 2007
Posts: 45
let's say your file looks like this;
.
.
.
aa
bb
cc
dd
ee
ff
gg
hh
ii
jj
kk
.
.

and let's say your string is gg
do you want to remove bb-ii (including bb,gg,ii) ? if it is;

currentline=`grep -n string inputfile|awk ' {print $1} '`
let "startingline=$currentline-5"
let "finishingline=$currentline+2"

sed -n "$startingline,${finishingline}!s/.*/&/p" inputfile>outfile
Reply With Quote