need help with creating a sh script

Hi everyone
I�m not a programmer and my knowledge of scripting is very poor, now I�m stock in a task at work and would really appreciate it if someone could help me out.
Here is the problem:

  1. I have a file with 9 million entries that look like this :
611424167
610864581
611881523
609585386
611022742
609283755
610960266

So basically there are 9 million lines and in each line there is a 9 digit number
2. I need to create a script that would group all these 9-digit numbers one after another with no space, put every to line into parentheses and add a text before every 10 line, which will eventually look like this :

Update table set location=55 (15848716,16743438,10116069,15635325,2281848545,16542381,10264272,537237738,16663957,10138040,10278391,1073929615,537578664,1074118324,1074201594,539647058,1074510375,1074414154,1074708478,1074746890,1075021290,1074513470,1075068666,1074988439,1075367528,540340963,1075597395,1075856225,1075902769,608293080,614368237,1075189157,1076843973,1077072172,1074201594,539647058,1074510375,1074414154,1074708478,1074746890,1075021290,1074513470,1075068666,1074988439,1075367528,540340963,1075597395,)
Update table set loation=55 15848716,16743438,10116069,15635325,2281848545,16542381,10264272,537237738,16663957,10138040,10278391,1073929615,537578664,1074118324,1074201594,539647058,1074510375,1074414154,1074708478,1074746890,1075021290,1074513470,1075068666,1074988439,1075367528,540340963,1075597395,1075856225,1075902769,608293080,614368237,1075189157,1076843973,1077072172,1074201594,539647058,1074510375,1074414154,1074708478,1074746890,1075021290,1074513470,1075068666,1074988439,1075367528,540340963,1075597395,)

your help would be very much appreciated...
i hope I hear from someone soon.:wall:

nawk -v n=10 '{fnr=FNR}FNR%n==1{printf "Update table set location=55 ("}{printf("%s", !(FNR%n)?")\n":$1 ",")}END{if(fnr%n) print ")"}' myFile 
gawk -v title="Update table set loation=55" 'NR%10==0{V=V","$0")"}
NR%10>1{V=V==0?$0:V","$0}
NR%10==1{V=V==0?title" ("$0:V"\n"title" ("$0}
END{print V}'

Thank you very much for your help, unfortunately I still couldn't successfully use these scripts and I'm sure it is because I'm not understanding it correctly ;

  1.   Where should I locate the file that the script should read from?
    
  2.   Where should I ask it to save the changes?
    
  3.   Should I save the script in a bash script?  \#!/bin/sh
    

I will try to find these answers myself as well but I'm running out of time and so desperate to find a solution, your help again would be very much appreciated.

So far , here is what I've managed to do :

� cat cingular.txt | xargs -n10 | awk '{ print $1","$2","$3","$4","$5","$6","$7","$8","$9","$10}' ( this command managed to make my file look like this : ( this goes on for almost 6 million lines)
� 613382230,614112492,642422294,614219643,614335239,614004204,611549637,610115247,611639280,611107468,
Now here is the logic of the command that I'm looking for :

  1.   For every 10 lines, add �update table set location=54 \(� at the beginning of the first line and put �,0\)� at the end of the 10th line.
    
  2.   Create one space line \( blank line \) after every 10 lines.
    
  3.   Repeat this task for 6000 times.
    

Again I really appreciate your help , thank you.

---------- Post updated at 12:55 PM ---------- Previous update was at 10:20 AM ----------

I think I figured out most of it, with a long , long way, probably you can find a much easier way.

sed 'n;n;n;n;n;n;n;n;n;n;s/^/update table set location= where location in
(/' file.txt > file2.txt

# add "," at the end of each line
sed 's/$/,/g' file.txt > file.txt

---------- Post updated at 12:56 PM ---------- Previous update was at 12:55 PM ----------

the only part that I'm stock with is this :

if a line begins with "update", add "0)" to the previous line

how can I do that through sed command ?