Sed issue with numbers exceeding 9
- by Imane Fateh
May be my problem is kinda obvious for you but I really need to get a solution. I need to generate a file.sql file from a file.csv, so I use this command :
cat file.csv |sed "s/\(.*\),\(.*\)/insert into table(value1, value2)
values\('\1','\2'\);/g" > file.sql
It works perfectly, but when the values exceed 9 (for example for \10, \11 etc...) it takes consideration of only the first number (which is \1 in this case) and ignores the rest.
I want to know if I missed something or if there is another way to do it.
Thank you !
EDIT :
The not working example :
My file.csv looks like
2013-04-01 04:00:52,2,37,74,40233964,3860,0,0,4878,174,3,0,0,3598,27.00,27
What I get
insert into table
val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13,val14,val15,val16
values ('2013-04-01
07:39:43',2,37,74,36526530,3877,0,0,6080,2013-04-01
07:39:430,2013-04-01 07:39:431,2013-04-01 07:39:432,2013-04-01
07:39:433,2013-04-01 07:39:434,2013-04-01 07:39:435,2013-04-01
07:39:436);
After the ninth element I get the first one instead of the 10th,11th etc...