我有多行,例如:
"390";"902";"from 4670000 to 4679999, from 4680000 to 4689999, from 9960000 to 9969999";"something1";"something2";"20.09.04"
"390";"903";"from 0770000 to 0779999, from 9170000 to 9179999";"something3";"something4";"09.09.04"
我需要的是:
"390";"902";"from 4670000 to 4679999";"something1";"something2";"20.09.04"
"390";"902";"from 4680000 to 4689999";"something1";"something2";"20.09.04"
"390";"902";"from 9960000 to 9969999";"something1";"something2";"20.09.04"
"390";"903";"from 0770000 to 0779999";"something3";"something4";"09.09.04"
"390";"903";"from 9170000 to 9179999";"something3";"something4";"09.09.04"
如您所见,我需要在 from/to 标记上拆分 variable3(注意有时在“,”之间有一个空格)。
理想情况下,我需要结果输出:
"390";"902";"4670000";"4679999";"something1";"something2";"20.09.04"
"390";"902";"4680000";"4689999";"something1";"something2";"20.09.04"
"390";"902";"9960000";"9969999";"something1";"something2";"20.09.04"
"390";"903";"0770000";"0779999";"something3";"something4";"09.09.04"
"390";"903";"9170000";"9179999";"something3";"something4";"09.09.04"
我已经发现我可以通过 awk 进行拆分,但我不确定如何复制该行的其余部分:
awk -F\, '{
for (i = 0; ++i <= NF;)
print i, $i
}' <<<'from 4670000 to 4679999, from 4680000 to 4689999, from 9960000 to 9969999'
1 from 4670000 to 4679999
2 from 4680000 to 4689999
3 from 9960000 to 9969999
对不起,这是我在这里的第一个问题,请随时指出我应该如何更正它以得到完全回答。
谢谢!