sh - split string by delimiter
问题 code s='id;some text here with possible ; inside' IFS=';' read -r id string <<< "$s" echo "$id" error restore.sh: 2: restore.sh: Syntax error: redirection unexpected bash version GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu) 回答1: 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. 回答2: A here string is just a shortcut for a small here document. This should work in any POSIX shell: