Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Deleting the lines exist between the Mattched Patterns

$
0
0
Hi,

I have a file with the content:

Code:


for name in \
sree\
rama\
laila\
srihari\
vicky\
john
do
  echo $name
done

I need to remove all the name lines that exist between for (first line) and do line so that i can replace with new names.

Output file should look like:
Code:


for name in \
do
echo $name
done

when i use the below command, it is deleting for line and do lines as well.

Code:

sed -i '/for/,/do/d' file
Please take for line and do line as a reference because we may not sure about the number of lines between for line and do line. Those lines get changed every time.

Thanks in advance!!

-SREE

Viewing all articles
Browse latest Browse all 16232

Trending Articles