This is working for me:
myvar=`cat`echo "$myvar"
The quotes around $myvar are important.
$myvar
In Bash, there's an alternative way; man bash mentions:
man bash
The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).
$(cat file)
$(< file)
$ myVar=$(</dev/stdin)hellothis is test$ echo "$myVar"hellothis is test
tee does the job
#!/bin/bashmyVar=$(tee)