SED - Change - Change lines which do NOT contain a specific string

Substitute “foo” with “bar” EXCEPT for lines which contain “baz”.

sed '/baz/!s/foo/bar/g'