‘+’ (one or more occurrences) not working with ‘sed’ command

If you are using GNU sed then you need to use sed -r which forces sed to use extended regular expressions, including the wanted behavior of +. See man sed:

-r, --regexp-extended

       use extended regular expressions in the script.

The same holds if you are using OS X sed, but then you need to use sed -E:

-E      Interpret regular expressions as extended (modern) regular expressions
        rather than basic regular regular expressions (BRE's).

Leave a Comment