fork download
  1. set -x
  2.  
  3. echo "=== EXAMPLE 1"
  4. echo "$(cat <<EOF
  5. hello \\
  6. world
  7. EOF
  8. )"
  9.  
  10. echo "=== EXAMPLE 2"
  11. echo "$(cat <<'EOF'
  12. hello \\
  13. world
  14. EOF
  15. )"
  16.  
  17. echo "=== EXAMPLE 3"
  18. set -o posix
  19. shopt -s xpg_echo
  20. echo "$(cat <<EOF
  21. hello \\
  22. world
  23. EOF
  24. )"
  25. set +o posix
  26. shopt -u xpg_echo
  27.  
  28. echo "=== EXAMPLE 4"
  29. cat <<EOF
  30. hello \\
  31. world
  32. EOF
  33.  
  34. echo "=== EXAMPLE 5"
  35. cat <<'EOF'
  36. hello \\
  37. world
  38. EOF
  39.  
Success #stdin #stdout #stderr 0.01s 5284KB
stdin
Standard input is empty
stdout
=== EXAMPLE 1
hello \world
=== EXAMPLE 2
hello \\
world
=== EXAMPLE 3
hello \world
=== EXAMPLE 4
hello \
world
=== EXAMPLE 5
hello \\
world
stderr
+ echo '=== EXAMPLE 1'
++ cat
+ echo 'hello \world'
+ echo '=== EXAMPLE 2'
++ cat
+ echo 'hello \\
world'
+ echo '=== EXAMPLE 3'
+ set -o posix
+ shopt -s xpg_echo
++ cat
+ echo 'hello \world'
+ set +o posix
+ shopt -u xpg_echo
+ echo '=== EXAMPLE 4'
+ cat
+ echo '=== EXAMPLE 5'
+ cat