I am trying to perform some modification on a typical g++ command line. I am trying to construct a regex looking for -o object_filename.o constructs. In order to test my matching pattern, I launch it in sed with an empty string as a substitution. But it does not work as expected since it removes nothing…
$echo "-o toto.o" | sed 's/-o [^ ]+//'
-o toto.o
You are missing a
-Eflag; without it,+is not treated as a regex meta-character:The above produces an empty output, as expected.