PDA

View Full Version : sed with regular expression


yan
03-04-03, 16:41
By using sed, how to express:
a pattern is found, but don't do anything to this line
e.g.: myfile has the following line and the pattern is "if"
aaaa
bbbb
if
cccc

I want to get:

echo aaaa
echo bbbb
if
echo cccc

Thanks for helping!

sathyaram_s
03-11-03, 13:20
cat myfile | sed '/if/!s/^/echo /g'

HTH

Sathyaram