Created
January 28, 2021 02:22
-
-
Save StudioEtrange/992610a2d7f783ffe19b5e6396e70126 to your computer and use it in GitHub Desktop.
inject file inline to command with heredoc
This file contains hidden or 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
# https://stackoverflow.com/a/38731052 | |
# variable substitution, leading tab retained, overwrite file, echo to stdout | |
tee /path/to/file <<EOF | |
${variable} | |
EOF | |
# no variable substitution, leading tab retained, overwrite file, echo to stdout | |
tee /path/to/file <<'EOF' | |
${variable} | |
EOF | |
# variable substitution, leading tab removed, overwrite file, echo to stdout | |
tee /path/to/file <<-EOF | |
${variable} | |
EOF | |
# variable substitution, leading tab retained, append to file, echo to stdout | |
tee -a /path/to/file <<EOF | |
${variable} | |
EOF | |
# variable substitution, leading tab retained, overwrite file, no echo to stdout | |
tee /path/to/file <<EOF >/dev/null | |
${variable} | |
EOF | |
# the above can be combined with sudo as well | |
sudo -u USER tee /path/to/file <<EOF | |
${variable} | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment