Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sed multi-line match help.

Status
Not open for further replies.

clonny2

MIS
Jan 28, 2003
470
US
I am having difficulty trying to get sed to match a sting and also grab the line before and the line after.

IE

#
# MY Text Goes Here
#


I want to match those 3 lines and i can do the rest, which is going to delete all 3 lines from my file.

 
You could use vi in a script :

vi yourfile << EOF
/# MY Text Goes Here
-
3dd
:wq
EOF

HTH
Dickie Bird (:)-)))
 
Thanx, but I need the script to run ni-interactively.
I can use vi in a script with out any problem . but thanks for the tip.
 
Here is the answer. I finally figured it out.

/^#/{
N
/^# My Text*/d
N
/^#/d
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top