I want to do string replacement using regular expressions in
sed. Now, I'm aware that the behavior of
sed is funky on a Mac. I've often seen workarounds using
egrep when I want to just examine a certain pattern in a line. But, in this case I want to do string replacement.
I want to replace
cp an and
cp <tab or newline> an with
gggg. I tried the following, which would work under extended regular expressions:
sed -i'_backup' 's/cp\s+an/gggg/g'
But of course this does nothing. I tried
egrepping, and of course it picks out the lines with
cp <one or more space characters> an.
How do I get
sed to do replacement using extended regular expressions? Or what is a better way to do replacement using regular expressions?
i'm on mac osx.