How do I insert a heredoc into a bash shell script?
-
Some background about Here Documents: https://en.wikipedia.org/wiki/Here_document
Simple here document in a bash shell script. When using
<<- EOF
The minus allows you to indent the code inside a here document.cat <<- EOF lunar2 has been $(uptime -p) EOF
The output of the script.
$ ./heredoc.sh lunar2 has been up 20 minutes
If we remove the minus from line one in the code, this is the result. The line appears with the indent included.
$ ./heredoc.sh lunar2 has been up 25 minutes
© Lightnetics 2024