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 QUESTION 1

Status
Not open for further replies.

johngiggs

Technical User
Oct 30, 2002
492
US
Using sed, how do I use sed to substitute multiple strings without creating a large pipeline? Currently I am using pipes to connect differend sed substitutions, but I want to do it using a single sed command. Below is an example of what I'm doing:

cat file | sed 's/tst/test/g' | sed 's/beta/alpha/g'

I want to make combine the two sed statements into one. How would I go about doing this?

Thanks,

John
 

EITHER:
sed -e 's/tst/test/g' -e 's/beta/alpha/g' file

OR
sed -e 's/tst/test/g;s/beta/alpha/g' file vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks, Vlad!! That's what I was looking for. I knew it was something simple, but I couln't think of the correct syntax.

Thanks,

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top