problem in greping the string from file using awk

I am using awk command for greping an value from the file
the file contains ..

file
----------------------------
content-----------
--------
String main = "81507066666";
------------------------------

i am greping the above value using awk command

NumberToReplace=`cat "file" | grep "String main"|awk -F '"' '{ print $2}'`
StringToReplace="String main = \"$NumberToReplace\""

when I echo the variable $StringToReplace ..the empty space is coming

echo $StringToReplace

out put
StringToReplace=String main = " 819066540205"

i want the output like

StringToReplace=String main = "819066540205"

pls help me out from this problem..waiting for the reply

thanks
vastare

I cannot reproduce the problem with the code you posted. The problem sounds like you have a space in your commands but you forgot to copy+paste precisely that space here ...?

vnix$ cat file
String main = "81507066666";
vnix$ NumberToReplace=`cat "file" | grep "String main"|awk -F '"' '{ print $2}'`
vnix$ StringToReplace="String main = \"$NumberToReplace\""
vnix$ echo "$StringToReplace"
String main = "81507066666"

Incidentally, cat | grep | awk is a magnificent Useless Use of Cat. Google for that. Here's a slightly less useless way to say that:

NumberToReplace=`awk -F '"' '/String main/ { print $2 }' "file"`

Anyway, if you want to replace that line in that file, you should probably be doing it all in a single awk command.

awk -F '"' -v newvalue="1234567" 'BEGIN { OFS=FS } /String main/ { $2 = newvalue; } { print }' "file"