Skip to content

Instantly share code, notes, and snippets.

@hnakamur

hnakamur/gist:9427958

Last active Aug 2, 2018
Embed
What would you like to do?
bashのヒアドキュメントでエスケープしたくない場合はEOFを'EOF'にします。
$ cat ./heredoc_escape.sh
#!/bin/bash
cat <<EOF
FOO=$6$
EOF
$ ./heredoc_escape.sh
FOO=$
$ vim ./heredoc_escape.sh
$ cat ./heredoc_escape.sh
#!/bin/bash
cat <<'EOF'
FOO=$6$
EOF
$ ./heredoc_escape.sh
FOO=$6$
$ vim ./heredoc_escape.sh
$ cat ./heredoc_escape.sh
#!/bin/bash
cat <<EOF
FOO=\$6$
EOF
$ ./heredoc_escape.sh
FOO=$6$
@hnakamur

This comment has been minimized.

Copy link
Owner Author

@hnakamur hnakamur commented Mar 8, 2014

20行目以降のように'EOF'ではなくEOFにしておいて中身をエスケープする手もあります。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.