What’s wrong with my lookahead regex in GNU sed?

sed -i '/^foo/! s/^/bar/' file.txt
  • -i change the file in place
  • /^foo/! only perform the next action on lines not ! starting with foo ^foo
  • s/^/bar/ change the start of the line to bar
     

Leave a Comment