I have a script a.sh build up an here document which looks like below
read -r -d "" message << EOF
line1
line2
line3
line4
EOF
then I want to pass this message (which contain four lines) to another program so I did
b.sh $message
however in b.sh I did
reMess=$1
cat $reMess
it only shows line1 not the rest 3 lines, could anyone explain what should I do to achieve this?
Second questions I changed the code in a.sh which make the message store in a file then read it from b.sh, could anyone suggest in b.sh how could I read this file in a here document please. code detail as below
a.sh
read -r -d "" message << EOF
line1
line2
line3
line4
EOF
echo "$message" > /tmp/message.txt
b.sh
read -r -d "" information << EOF
inforation1
$(cat /tmp/message.txt)
EOF
echo "$information"
it return me nothing any suggestion where is wrong? Thank you for your help