This is what I'm doing (simplified example):
gsed -i -E 's/^(?!foo)(.*)$/bar\1/' file.txt
bar
foo
gsed: -e expression #1, char 22: Invalid preceding regular expression
As far as I know sed
has not neither look-ahead nor look-behind. Switch to a more powerful language with similar syntax, like perl
.