Due to some constraints, i have to transfer local file to remote ssh with only echo
and cat
command and here-document.
I’ve tried:
#!/bin/bash
SSH_CMD=xxx # suppose `SSH_CMD` is my ssh command
w="$(cat word)"
SSH_CMD <<EOF1
cd /data00
touch for-test
echo $w >> for-test
echo "abc" >> for-test
EOF1
And word is a file with multiple lines:
#!/bin/bash
line1
line2
line3
After i run the script, the /data00/for-test file only contains one line: abc, quite strange.