insert dummy values in a file

Hey guys, i have a file a.txt and i need to insert a dummy data into it as per the below pattern..

bash:

cat a.txt
1234,34
3434,45
4545,56
3434,56

Now i need the file in the below pattern

1234,34,a0001,C_01
3434,45,a0002,C_02
4545,56,a0003,C_03
3434,56,a0004,C_04

here the count of file is 4, but in real the count is in crores.

Need you help as in how to insert the dummy data in ascending order as mentioned above.

Thanks in advance..!!! :slight_smile:

Something like this?

awk '{$0=$0",a"sprintf("%04d",NR)",C_"sprintf("%02d",NR)}1' file

Thanks mahn... It's working..!!!

what if i need the same values in the new columns???

i mean in the last two coloumns...!!!

---------- Post updated 02-11-12 at 11:35 AM ---------- Previous update was 02-10-12 at 08:16 PM ----------

hey guys,

one more thing.. i need to run this file on daily basis... though i need to make sure that i continue with the next series.

like yesterday if the last line was 3434,56,a0004,C_04 then today if i again run the same command, it continues with 3343,343,a0005,C_05.

The next time i run this command,I need to continue the series..

Kindly suggest how it can be done..

if you want to add new rows in current file or new one? In current file, you should count the current rows and add new column value; if not, should reference the last file's row count.