我正在尝试解析 .csv 文件,但 IFS 存在一些问题。该文件包含如下行:
"Hello","World","this","is, a boring","line"
列用逗号分隔,因此我尝试使用以下代码分解该行:
IFS=, read -r -a tempArr <<< "$line"
但我得到这个输出:
"Hello"
"World"
"this"
"is
a boring"
"line"
我明白为什么,所以我尝试了其他一些命令,但没有得到预期的输出。
IFS=\",\"
IFS=\",
IFS=',\"'
IFS=,\"
每次将第三个元素分成两部分。如何使用 IFS 将字符串分成 5 个这样的部分?
"Hello"
"World"
"this"
"is, a boring"
"line"