split line into multiple via splitting specific field
I have multiple lines like:
"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"
What I need is:
"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"
As you can see I need to split variable3 on from/to tag (NOTE there is a
space sometimes between ",").
Ideally, I need resulting output:
"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"
I've already found out I can split via awk, but I'm not sure how to copy
rest of the line:
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
Sorry, this is my first question here, feel free to point me how should I
correct it in order to get it fully answered.
Thanks!
No comments:
Post a Comment