fork download
  1. #!/bin/bash
  2. s="abcd'"'efgh\ ijkl\ mnop'
  3. sed 's/'"'"'/\\&/g' <<< "$s"
Success #stdin #stdout 0.01s 5448KB
stdin
Standard input is empty
stdout
abcd\'efgh\ ijkl\ mnop