Computing.Net > Forums > Unix > merge files into one

merge files into one

Reply to Message Icon

Original Message
Name: phamq76
Date: March 14, 2008 at 18:34:57 Pacific
Subject: merge files into one
OS: unix
CPU/Ram: sun aix
Model/Manufacturer: sun
Comment:

I think this should be a very simple task for UNIX guru. I try to learn how to do this.

I have many files reside in a directory. The name can be change without limitation in length except the portion after the date and sequence number of the file:

$num_$area_$date_$SeqNo.txt

Ex:

100_Custid_20080310_1.txt
100_Custid_20080310_2.txt
100_Custid_20080310_3.txt
100_Custid_20080310_4.txt

96_PhhoneID_20080311_1.txt
96_PhhoneID_20080311_2.txt
96_PhhoneID_20080311_3.txt

118_CityCD_20080312_1.txt
118_CityCD_20080312_2.txt

Since each file is created by different person. So number of file in each group is unknown. $area can be any name too.

Question is how can I create a ksh script to merge (cat f1 f2 f3 > f_combine) all files belong to same group.
For the sample file in directory above the result should look like this

100_Custid_20080310_merged.txt

96_PhhoneID_20080311_merged.txt

118_CityCD_20080312_merged.txt

Thanks

Unix rookie


Report Offensive Message For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: merge files into one

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software