To combine data using gawk
here my data : Examples :
> 454|12 13 |Peoples Telephone (China Mobile Hong Kong)|0.0118
> 454|06 15 17 |SmarTone Mobile Comms (P Plus)|0.0412
im quite new unix/linux. May i know is there any command so i can populate data as below:
> 45412 |Peoples Telephone (China Mobile Hong Kong)|0.0118
> 45413 |Peoples Telephone (China Mobile Hong Kong)|0.0118
> 45406 |SmarTone Mobile Comms (P Plus)|0.0412
> 45415 |SmarTone Mobile Comms (P Plus)|0.0412
> 45417 |SmarTone Mobile Comms (P Plus)|0.0412
I using gawk command to print the first part
> ( gawk 'BEGIN{FS="|"}{print $1}'
but failed to combine with each breakout. Need your assistance.
gawk 'BEGIN{FS="|"}{n=split($2,a," "); for (i = 1; i <=n ; i++) printf "%s%s|%s|%s\ ", $1,a[i],$3,$4;}'