解决方法
这实际上非常困难.我想出了以下awk脚本,它手动拆分行并将所有字段存储在一个数组中.
@H_301_3@{
s = $0
i = 0
split("",a)
while ((m = match(s,/"[^"]*"/)) > 0) {
# Add all unquoted fields before this field
n = split(substr(s,1,m - 1),t)
for (j = 1; j <= n; j++)
a[++i] = t[j]
# Add this quoted field
a[++i] = substr(s,RSTART + 1,RLENGTH - 2)
s = substr(s,RSTART + RLENGTH)
if (i >= 3) # We can stop once we have field 3
break
}
# Process the remaining unquoted fields after the last quoted field
n = split(s,t)
for (j = 1; j <= n; j++)
a[++i] = t[j]
print a[3]
}