Use the -r
option to remove the need to backslash everything.
sed -r 's/(.*#).*- (.*) (.*)/\1\2/' file
, their basic regular expressions
level treats parens and many other regex characters as literal. But as a gnu extension you can backslash escape them to enable their special meanings.
But when you use the extended regular expressions
(sed -r/grep -E/egrep), everything is reversed. All regex characters are enabled by default, and escaping disables them.
Check out the grep man page for details (and the info
page for even more).