here document and double backslash

后端 未结 2 1794
被撕碎了的回忆
被撕碎了的回忆 2021-01-18 11:36

If I use a here document in a shell script that contains multiple backslashes \'\\\\\', the shell translates it into a single backslash. Can I work around this without chang

相关标签:
2条回答
  • 2021-01-18 11:44

    As an alternative to what Dennis mentions The command sed can also take care of this.

    sed 's/\\/\\\\/g' <<EOF
    Print \\hello \\world
    EOF
    
    0 讨论(0)
  • 2021-01-18 11:59

    Quote the beginning here document marker:

    cat <<'EOF'
    Print \\hello \\world
    EOF
    
    0 讨论(0)
提交回复
热议问题