Reputation: 389
I want to replace a special character (=) only at first occurrence.
Example:
abc=abc.def=
Expected output is:
abc.def=
I tried the following command: sed -e 's/\([^=]*\)\(=.*\)/\2/'
but the output I am getting is:
=abc.def=
Upvotes: 0
Views: 1373
Reputation: 425348
Note that your example suggests you want to remove everything up to and including the first equals.
Move the equals sign into the first part of the regex, delete the remaining part of the regex (because you only need to match the part you want to remove) and replace the match with "nothing" to remove it:
sed -e 's/^[^=]*=//'
Upvotes: 2