📜  bash 将字符串拆分为变量 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:50:59.613000             🧑  作者: Mango

代码示例1
# 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}"