IFS分隔符的使用
data="name, gender,rollno,location"
我们可以使用IFS读取变量中的每一个条目。
oldIFS=$IFS
IFS=, #IFS现在被设置为,
for item in $data;
do
echo Item: $item
done
IFS=$oldIFS
输出如下:
Item: name
Item: gender
Item: rollno
Item: locationdata="name, gender,rollno,location"
data="name, gender,rollno,location"
我们可以使用IFS读取变量中的每一个条目。
oldIFS=$IFS
IFS=, #IFS现在被设置为,
for item in $data;
do
echo Item: $item
done
IFS=$oldIFS
输出如下:
Item: name
Item: gender
Item: rollno
Item: locationdata="name, gender,rollno,location"