[lug] is sed broken?

Tom Tromey tromey at redhat.com
Sat Jul 13 18:55:20 MDT 2002


>>>>> ">" == D Stimits <stimits at idcomm.com> writes:

>> For regular expression, where bar is unkown, but foo is known, normally
>> I would think that I could use this:
>>   foo[=]["].*["]

Yes, though you don't need the []:

    foo=".*"

is a valid sed regexp.

>> My sed is similar to:
>>   cat some.file | sed "s/foo[=]["].*["]/foo="new_value"/" -

You're experiencing a sed/sh quoting interaction problem.
Use single quotes around the sed expression and you'll be ok.
This worked for me:

    fleche. cat /tmp/X
    foo="bar"
    fleche. sed 's/foo=".*"/foo="new_value"/' < /tmp/X
    foo="new_value"

Tom



More information about the LUG mailing list