Last active
March 20, 2021 15:56
-
-
Save michel47/f799d5ca79e5bd889ab68ace9df07a8c to your computer and use it in GitHub Desktop.
how to get a multiline string in a shell variable using <<EOT
This file contains 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
# | |
# 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