我正在尝试逐行解析一个csv文件,其格式类似于以下内容:
"name","content1,with commas as you see", "content2, also may contain commas", "..."
...
...
我想获取特定列的内容,不包括引号。例如:第一列和第三列。所期望的内容应为:
name (if get column 1)
content2, also may contain commas (if get column 3)
我尝试使用awk,但它没有起作用。此外,我还尝试了:
while IFS=, read col1 col2 col3 col4;
do
echo "got ${col1}|${col3}";
done < file
但是它包含了引号"",而且col3的内容是错误的,混入了每列内部的逗号。那么我应该如何分割这种在每个列中包含逗号的格式呢?