bash split string on character code example
Example 1: bash split string into variables
# separator is space
VAR="inforge srl bergamo"
read -r ONE TWO THREE <<< "${VAR}"
echo ${ONE}
echo ${TWO}
echo ${THREE}
# separator is comma
VAR="inforge,srl,bergamo"
IFS="," read -r ONE TWO THREE <<< "${VAR}"
echo "${ONE} ${TWO} ${THREE}"
Example 2: split bash string
IN="[email protected];[email protected]"
arrIN=(${IN//;/ })
Example 3: bash split variable by delimiter
IFS='|' read -r -a arrayName <<< "$variable"