Need tips on file manipulation

Hi,

I am new to unix and have a query. I have a text file which has a list of invoice numbers (00044779). There is some data (alphabetic) which follows this number. Than the second invoice number appears(00044898) and again some data follows.

I need a script which reads the whole file and when it hits any invoice number, it picks that and the data following it and puts it into a file. Similarly than when it encounters the second invoice, it picks the number and data following it and writes into another output file.

Can it be done by unix and if yes can you please guide me a bit?

Hi.

Could you please post a sample of data that reflects your requirement?

Otherwise, this makes assumptions:

awk '/^[0-9]{8}/ FS { print > FILENAME "_invoice_" $1}' input_file

00044779
aaaaaaaaaaaaaaaaaaaaaaaaaa
ccccccccccccccccccccccccccc
vvvvvvvvvvvvvvvvvvvvvvv
bbbbbbbbbbbbbbbbbbbbbbb
00044898
ccccccccccccccccccccccccccc
vvvvvvvvvvvvvvvvvvvvvvv
bbbbbbbbbbbbbbbbbbbbbbb
00044799
sssssssssssssssss
dddddddddddddd
gggggggggggggg
hhhhhhhhhhhhhhh
hhhhhhhhhhhhhh

while(<>)  {
    if ( /^\d{8}$/ )  {
        close FH;
        $filename = $_;
        open FH, ">$filename";
    }  else  {
        print FH "$_";
    }
}

It will work, but this is not an efficient or standard way to do things.