awk command to split in to 2 files

Hi,
I have a problem in grepping a file for 2 strings and writing them to 2 appropriate files. I need to use the awk command and read the file only once and write to the appropriate file.
My file is very huge in size and it is taking a long time using cat command and grep command.
Can anyone help me with using the awk command for this?

You may modify this to work for your requirement
Thanks
Ashok

awk '
{
if ( substr($0,1,1) == "A")
print $0 >>FILE1
if ( substr($0,1,1) == "B")
print $0 >>FILE1

 \}' FILE1="file_1"  FILE2="file_2" test.data     

~

If your file is really as big as you suggest you would get much better performance using perl.

instead of using a cat and then a grep --- just grep directly out of the file ...

this ...
    grep string /dir/file

not this ...
    cat /dir/file | grep string