fork download
  1. #!/bin/bash
  2. s='AFM_7499_190512_110136_001_p_EQ4H_1_s60_0012__386___Day_'
  3. echo "$s"
  4. sed -E 's/([^_]|^)__([^_]|$)/\1.abc.def__\2/g' <<< "$s"
  5. perl -i -pe 's/(?<!_)__(?!_)/.abc.def__/g' <<< "$s"
Success #stdin #stdout #stderr 0.01s 5376KB
stdin
Standard input is empty
stdout
AFM_7499_190512_110136_001_p_EQ4H_1_s60_0012__386___Day_
AFM_7499_190512_110136_001_p_EQ4H_1_s60_0012.abc.def__386___Day_
AFM_7499_190512_110136_001_p_EQ4H_1_s60_0012.abc.def__386___Day_
stderr
-i used with no filenames on the command line, reading from STDIN.