Created
September 9, 2017 20:33
-
-
Save paradigm/24cd644e9b7beafcc7e6f220d53d7449 to your computer and use it in GitHub Desktop.
heredoc explanation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ # literal because it's a single-quote string | |
$ echo '$HOME' | |
$HOME | |
$ # interpreted because it's a double-quote string | |
$ echo "$HOME" | |
/home/paradigm | |
$ # interpreted again because it's a double-quote string despite containing single quotes within it | |
$ echo "'$HOME'" | |
'/home/paradigm' | |
$ # to print the literal with the interpreted string, have to escape | |
$ echo "\$HOME" | |
$HOME | |
$ # interpreted because it's a heredoc | |
$ cat <<EOF | |
heredoc> $HOME | |
heredoc> EOF | |
/home/paradigm | |
$ # interpreted again because it's a here-doc despite containing single quotes within it | |
$ cat <<EOF | |
heredoc> '$HOME' | |
heredoc> EOF | |
'/home/paradigm' | |
$ # to print the literal with the interpreted string, have to escape | |
$ cat <<EOF | |
heredoc> \$HOME | |
heredoc> EOF | |
$HOME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment