s='id;some text here with possible ; inside'
IFS=';' read -r id string <<< "$s"
echo "$id"
restore.sh: 2: restore.sh: Syntax error: redirection unexpected
bash version GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu)
A here string is just a shortcut for a small here document. This should work in any POSIX shell:
string='id;some text here with possible ; inside'
IFS=';' read -r id string <<EOF
$string
EOF
echo "$id"
You seem to be using sh to execute the script. Herestrings aren't supported in sh; hence the error.
Ensure that you're using bash to execute the script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With