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 changing the text ?
$ cat
<<EOF
> Print \\hello \\world
> EOF
Print \hello \world
A HereDoc is a multiline string or a file literal for sending input streams to other commands and programs. HereDocs are especially useful when redirecting multiple commands at once, which helps make Bash scripts neater and easier to understand.
A here document is a special-purpose code block. It uses a form of I/O redirection to feed a command list to an interactive program or a command, such as ftp, cat, or the ex text editor. Choose a limit string sufficiently unusual that it will not occur anywhere in the command list and confuse matters.
In computing, a here document (here-document, here-text, heredoc, hereis, here-string or here-script) is a file literal or input stream literal: it is a section of a source code file that is treated as if it were a separate file.
Quote the beginning here document marker:
cat <<'EOF'
Print \\hello \\world
EOF
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With