fork download
  1. #!/bin/bash
  2. s="some thing <phrase>a phrase</phrase> some thing else <phrase>other stuff</phrase>"
  3. perl -pe 's{>.*?</}{ $& =~ tr/ /_/r }eg' <<< "$s"
Success #stdin #stdout 0s 19632KB
stdin
Standard input is empty
stdout
some thing <phrase>a_phrase</phrase>_some_thing_else_<phrase>other_stuff</phrase>