I need to replace a value that matches a string=value
so this is what I’ve came up with:
echo "some string=oldvalue" | sed 's/\(some string\=\)(.*)/\1newvalue/'
It works fine, I just wonder if there’s a better, shorter way to accomplish the same
TIA
If
some_stringis a constant value, just use:as per the following transcript:
But you may want to consider using a start marker so that you don’t pick up other keys:
If you wanted to preserve the rest of the line (say, after a space), use:
This works by limiting the item after the
=to non-space characters.