Skip to content

Instantly share code, notes, and snippets.

@michel47
Last active March 20, 2021 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michel47/f799d5ca79e5bd889ab68ace9df07a8c to your computer and use it in GitHub Desktop.
Save michel47/f799d5ca79e5bd889ab68ace9df07a8c to your computer and use it in GitHub Desktop.
how to get a multiline string in a shell variable using <<EOT
#
# for sh
solution="$(cat <<-EOT
use cat instead of read
and don't forget
to use "" to protect your "\\\\n"
to be replaced w/ spaces.
EOT
)"
echo "solution: $solution"
if test -z "$(type -p)"; then
echo and for $SHELL ...
read -d '' msg <<EOT
this is a multi line
text to be placed
in a variable '\$msg'
let's see if it works !
+mgc
EOT
echo "msg: $msg"
fi
echo
echo check the shell that is run :
echo 0: $0
ps -$$
echo .
exit $?
true; # $Source: /my/shell/scripts/read_multiline.sh $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment