Example task: if a line contains foo
, replace it with bar
, otherwise append baz
to the line.
sed -e s/foo/bar/ -e s/$/baz/
doesn't work, as the second command gets executed whether or not the first one matches. Is there a way to tell sed
to go to the next line after a match?