Split and Rename multiple files

Hi,

I have a data file like below

messageid|email|timestamp
750452173|123@googlemail.com|2013-05-24 16:14:32
750464921|000@gmail.com|2013-06-13 19:38:01
750385426|001@googlemail.com|2013-01-06 12:06:36
750373470|000@wz.eu|2012-11-30 22:32:07
.
.

I want to split the files based on the first column (messageid),
Output file name should be like below

750452173-RE-file1.csv (This file should contain only the same message id)
750464921-RE-file2.csv (This file should contain only the same message id)
750385426-RE-file3.csv (This file should contain only the same message id)
750373470-RE-file4.csv (This file should contain only the same message id)
.
.

Could you please provide the unix command or perl script?

Thanks,
Saravanan

This is not too difficult for the data lines only; did you try anything? If you want to keep the header for each file, additional measures must be taken. Try (and adapt)

awk 'NR>1 {print >> $1"-RE-file"++CNT".csv"}' FS=\| OFS=\| file

Thanks Rudic.

But its not working as per my requirements.

If we have more than one row with the same message id then it should be present in one output file. (Not separate output file)
Input :

750452173|123@googlemail.com|2013-05-24 16:14:32
750464921|000@gmail.com|2013-06-13 19:38:01
750385426|001@googlemail.com|2013-01-06 12:06:36
750373470|000@wz.eu|2012-11-30 22:32:07
750452173|120@googlemail.com|2013-05-24 16:14:32
750385426|000@googlemail.com|2013-01-06 12:06:36
750452173|1230@googlemail.com|2013-05-24 16:14:32

Output File:
File Name : 750452173-RE-file1.csv

750452173|123@googlemail.com|2013-05-24 16:14:32
750452173|120@googlemail.com|2013-05-24 16:14:32
750452173|1230@googlemail.com|2013-05-24 16:14:32

File Name : 750464921-RE-file2.csv

750464921|000@gmail.com|2013-06-13 19:38:01

File Name : 750373470-RE-file3.csv

750373470|000@wz.eu|2012-11-30 22:32:07

File Name : 750385426-RE-file4.csv

750385426|001@googlemail.com|2013-01-06 12:06:36
750385426|000@googlemail.com|2013-01-06 12:06:36

Well, try

awk    'NR==1         {next}
        !($1 in T)    {T[$1]=++CNT}
                      {print >> $1"-RE-file"T[$1]".csv"}
    ' FS=\| OFS=\| file

Thanks Rudic.

Its working fine.