我的示例CSV文件是:
test1,a=1,b=2
test2,c=3,d=4
我可以使用
获取字段test1 a = 1 b = 2while read f1 f2 f3
do
echo $f1
echo $f2
echo $f3
done < filename.csv
但我希望单独阅读a=1
并将a
保存在param1中,将1
保存在param2中。我想为所有的f2&amp; f3一个接一个。
有人可以帮助我吗?
答案 0 :(得分:1)
您可以将IFS设置为逗号或等号,如下所示:
while IFS=",=" read a b c d e
do
echo $a
echo $b
echo $c
echo $d
echo $e
done < file
<强>输出强>
test1
a
1
b
2
test2
c
3
d
4