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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I do 2 substitutions in ONE cmdline with sed?

Status
Not open for further replies.

michael3

Programmer
Aug 8, 2001
26
US
Hi,

Can anyone tell me if I could be able to run two substitutions in one sed command line. Say,

$sed 's/the/THE/g' input > output
$sed 's/1/2/g' output > input

Do sed allow me to do the above ( 2 commands ) in a single one? Many Thanks,

David
 
sed 's/the/THE/g;s/1/2/g'
or
sed -e 's/the/THE/g' -e 's/1/2/g' vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
sed lets you do up to 100 commands per script.

FYI: If you don't have to save intermediate data to disk - don't. Disk I/O is pretty heavy on overhead and seek time, etc... So Vlad's solution or even
Code:
sed 's/the/THE/g' | sed 's/1/2/g' output > input
is better than the two lines. Cheers,
ND [smile]

bigoldbulldog@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top