|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Creating a control file for a group of files
Hi, We have almost 45,000 data files created by a script daily. The file names are of format-ODS.POS.<pharmacyid>.<table name>.<timestamp>.dat. There will be one data file like this for each pharmacy and each table.(Totally around 45,000) The requirement is to create a control file for each pharmacy id with file name, No.of rows , table name, timestamp and MD5 value. The data files look like this - Code:
ODS.POS.ABC89.ADT_LOG.07272010_033303.dat ODS.POS.AEC12.ADT_LOG.07272010_033303.dat ODS.POS.ABC78.ADT_LOG.07272010_033303.dat ODS.POS.AEC12.TR_ITM_CPN_TND.07272010_033303.dat ODS.POS.AEC13.TR_ITM_CPN_TND.07272010_033303.dat ODS.POS.ABC89.TR_ITM_CPN_TND.07272010_033303.dat ODS.POS.ABC78.TR_ITM_CPN_TND.07272010_033303.dat The requirement is to create a control file for each pharmacyid Controlfile 1 -> for pharmacy id - ABC89 Control file 1 (ODS.POS.<Pharmacyid>.timestamp.ctl )should contain the filename, no.of rows, table name, time stamp and MD5 value for the below files. Code:
ODS.POS.ABC89.ADT_LOG.07272010_033303.dat ODS.POS.ABC89.TR_ITM_CPN_TND.07272010_033303.dat Control file 2->for pharmacy id - AEC12 Control file 2 ((ODS.POS.<Pharmacyid>.<timestamp>.ctl )should contain the filename, no.of rows, table name, time stamp and MD5 value for the below files. Code:
ODS.POS.AEC12.ADT_LOG.07272010_033303.dat ODS.POS.AEC12.TR_ITM_CPN_TND.07272010_033303.dat can somebody help on this? Thanks Maya Last edited by Scott; 08-02-2010 at 05:16 AM.. Reason: Code tags, please... |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
Hi, Try This, Code:
#!/usr/bin/perl
`ls ODS.POS.*.dat > filelist`;
$timest=`date '+%m%d%Y_%H%M%S'`;
chop($timest);
open (FH,"<","filelist");
while (<FH>) {
chomp;
if (/(.+?)\.(.+?)\.(.+?)\.(.+?)\..*/) {
$ctl='ODS.POS';
$ctl="$ctl.$3.$timest.ctl";
open (FW,">>","$ctl");
print FW "File name - $_ \n";
print FW "Table Name - $4 \n";
$checksum=`md5sum $_ | cut -d " " -f1`;
$row_cnt=`wc -l $_ | cut -d " " -f1`;
chop($checksum,$row_cnt);
print FW "Row Count - $row_cnt \n";
print FW "md5Checksum - $checksum \n";
print FW "--------------------------------------\n";
}
}
close(FH); |
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
Thank you so much .. Its Perfect
![]() Maya |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a Tar file while files are spooling | sgarvan | UNIX for Dummies Questions & Answers | 1 | 06-25-2010 06:15 AM |
| Restoring a single file from a group of files using tar | rahmantanko | UNIX for Dummies Questions & Answers | 1 | 03-11-2010 09:54 AM |
| ls > file - Creating file containing the list of all files present in a directory | pranavagarwal | Shell Programming and Scripting | 1 | 09-26-2008 08:37 PM |
| creating files and getting input from another file | ajayyadavmca | Shell Programming and Scripting | 10 | 09-05-2008 01:00 AM |
| listing files excluding files from control file | ukatru | UNIX for Advanced & Expert Users | 15 | 08-15-2008 08:24 PM |
|
|