I'm trying to split a string into two variables (without having to use a while loop):
var="hello:world"
IFS=':' read var1 var2 <<< $var
echo "var1: $var1"
echo "var2: $var2"
but i'm not getting the desired result:
var1: 'hello world'
var2: ''
Could anybody please explain if it's possible to do it this way (or similar way)?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…