fork(1) download
  1. #!/bin/bash
  2.  
  3. # ideone boilerplate: run in temp dir
  4. t=$(mktemp -d -t ideone.XXXXXXXX) || exit
  5. trap 'rm -rf "$t"' ERR EXIT
  6. cd "$t"
  7.  
  8. cat <<\: >input.txt
  9. there is a foo
  10. in your bar
  11. :
  12.  
  13. cat <<\: >test.txt
  14. <body>
  15. <div>PLACE_HOLDER</div>
  16. </body>
  17. :
  18.  
  19. sed 's/\&/\\&/g
  20. 1s/^/s\&PLACE_HOLDER\&/
  21. $!s/$/\\/
  22. $s/$/\&/' input.txt
  23.  
  24. echo ----------
  25.  
  26. sed 's/\&/\\&/g
  27. 1s/^/s\&PLACE_HOLDER\&/
  28. $!s/$/\\/
  29. $s/$/\&/' input.txt |
  30. sed -f - test.txt
  31.  
Success #stdin #stdout 0.01s 5380KB
stdin
Standard input is empty
stdout
s&PLACE_HOLDER&there is a foo\
in your bar&
----------
<body>
  <div>there is a foo
in your bar</div>
</body>