How to use a here documents to write data to a file in bash script
How to use a here documents to write data to a file in bash script allow here-documents within shell scripts to be indented in a natural fashion using EOF<<- command <<-EOF msg1 msg2 $var on line EOF Disabling pathname/parameter/variable expansion, command substitution, arithmetic expansion with 'EOF' #!/bin/bash OUT=/tmp/output.txt echo "Starting my script..." echo "Doing something..." # No parameter and variable expansion, command substitution, arithmetic expansion, or pathname expansion is performed on word. # If any part of word is quoted, the delimiter is the result of quote removal on word, and the lines in the here-document # are not expanded. So EOF is quoted as follows cat <<'EOF' >$OUT Status of backup as on $(date) Backing up files $HOME and /etc/ EOF echo "Starting backup using rsync..."