Multiline text in bash
, automation | bash
#!/bin/bash -e

CUSTOM_VALUE=$( date )
ANOTHER_VALUE="String value:"
YET_ANOTHER_VALUE="More information"

set +e # read fail for some reason, disable error handling

# multiline variable
read -r -d '' MULTILINE_BASH_VARIABLE << EOL
The MULTILINE_BASH_VARIABLE contain this line
and all the rest until the

  'End Of Line' tag, which can be anything
  as long it is not in the multiline itself

Bash variables can be included
Custom value: '$CUSTOM_VALUE'
${ANOTHER_VALUE}added:${YET_ANOTHER_VALUE}
EOL

set -e

# multiline file
cat > ./README << ANYTHING
The README file at call location will contain this line
  and all the rest until

  'Anything' tag

Bash variables can be included
Custom value: '${CUSTOM_VALUE}'
${ANOTHER_VALUE}added:${YET_ANOTHER_VALUE}
ANYTHING

printf "\n\n  OUTPUT: bash variable:\n\n"
echo "${MULTILINE_BASH_VARIABLE}"

printf "\n\n  OUTPUT: ./README file:\n\n"
cat "./README"
printf "\n\n"