Generating millions of record using shell script

Hi All,

My requirement is like this.
I want to generate records of 1 million lines. If I say lines it means one line will contain some string or numbers like

AA,3,4,45,+223424234,Tets,Ghdj,+33434,345453434,........................ upto length lets say 41. ( 41 comma sepearted aplha numneric values ).
Now i want 5, 7 and 23 field should be unique or in some incremental order for ex.  if in first line value is 33 then next line, same fields position value should be 34 and so on. All other fields in all the lines can be same
Now for reference this script should refer one sample file and based of that it will create a file with 1 million lines. In my case following is my reference file

1,10,+91900000000,+9112323230000,,1,60,25/1/200923:10:10,3534671234500001,40591912000000001,1001001,1,1,10,3,1,1,1,0,20,+91900000000,329,ss,in_flag,digits,IC_TRUN,OG_TRUNK,NET_IND,realer_st,switch,source,plmn,1,cug_code,ff_call,corela,service3g,conf,op1,op2,op3

I want 3,4 and 21 field as as unique rest filed can be same.

Please help me out in this as am new to shell scripting.

rd-

You can try something like this.

In this example, 2nd,3rd,5th fields are unique in each line.

for i in $(seq 10);
    do
        echo "a,2,c,d,5,6" | awk -v v=$i 'BEGIN {FS=OFS=","} {$2=v$2;$3=v$3;$5=v$5}{print}'
done

Output:
a,12,1c,d,15,6
a,22,2c,d,25,6
a,32,3c,d,35,6
a,42,4c,d,45,6
a,52,5c,d,55,6
a,62,6c,d,65,6
a,72,7c,d,75,6
a,82,8c,d,85,6
a,92,9c,d,95,6
a,102,10c,d,105,6

You can also use Bash "RANDOM" to make them very unique.

Thanks a tonne, it really worked after doing some customization to your script to get my desired result.

Once again thanks for replying so quikly:):slight_smile:

My final Script is somethin like this

#!/bin/bash
> VoiceCDR.txt
echo "Recordtype:1"  >> VoiceCDR.txt

for i in $(seq 1000);
    do
        echo "2009/11/07 13:45:15,1024,+9199511000,+9198000000,,1,42,2009/11/07 13:45:15,,4059192908198221,,3,1025,0.596,1,1,1,1,,0,0,+9199511000,,CallType_Out_Int,,,919032006820,,,,,,,,19,,0,,1,,Account-1,269192908198221,,,," | awk -v v=$i 'BEGIN {FS=OFS=","} {$3=+$3+v;$4=+$4+v;$22=+$22+v}{print}' >> VoiceCDR.txt
done

perl -pi -e "s:,91:,+91:g" VoiceCDR.txt

rd-