'sed' replacement does not seem to work on the command line The following command:

echo "/tmp/ansible_gN946Q/chronograf-1.4.0.1-1/etc/blue" | sed  's/(((chronograf|influxdb|kapacitor).[0-9\.-]*\/)|telegraf\/)/aefgae/g'


Outputs:

/tmp/ansible_gN946Q/chronograf-1.4.0.1-1/etc/blue


When the expected output is:

/tmp/ansible_gN946Q/aefgaeetc/blue


This is strange because it replaces fine in PCRE, which sed should be compatible with, correct me if I am wrong.

Hope someone can point out my error in the sed command above.
The following works:

sed -E 's:(((chronograf|influxdb|kapacitor).[0-9.-]*/)|telegraf/):aefgae:g'&lt;&lt;&lt;'/tmp/ansible_gN946Q/chronograf-1.4.0.1-1/etc/blue'


Outputs:

/tmp/ansible_gN946Q/aefgaeetc/blue


Differences between your implementation and mine:


Using -E option with sed


Interpret regular expressions as extended (modern) regular
     expressions rather than basic regular expressions (BRE's).  The
     re_format(7) manual page fully describes both formats.

Using &lt;&lt;&lt; instead of echo and |
Using : as a seperator instead of / in the sed expression because the input has / in it.
Using ' instead of " around input so no shell expansion occurs on input.


Note: You could still use echo and | however it's a needless use of echo when it doesn't need to be used. Otherwise, the other differences, using -E and : as a separator instead of /, because input has / in it, is really what fixes what's wrong in your implementation.