Operating System - HP-UX
1827158 Members
1990 Online
109716 Solutions
New Discussion

Shell script - forming tar file name based on grouping of specific filenames

 
Danny Fang
Frequent Advisor

Shell script - forming tar file name based on grouping of specific filenames

Hi,

I have a SHELL script attached in this posting to the filenames and group the files to be tar-ed according to some criteria.

The filename have the following format:
A20060406.0015-0031_SubNetwork=SE,SubNetwork=RNC202,MeContext=RNC202_statsfile.xml
A20060406.0015-0031_SubNetwork=SE,SubNetwork=RNC202,MeContext=RNC202_statsfile.xml

A20060307.0017-0031_SubNetwork=SE,SubNetwork=RNC202,MeContext=RNC202_statsfile.xml
A20060307.0017-0031_SubNetwork=SE,SubNetwork=RNCABC,MeContext=RNCABC_statsfile.xml

The tar filename which contains the grouping of the necessary file has the following naming convention:
A.-__statsfile.GPEH.xml.tar

I need to tar the files according to the following elements from the filename:
start_date: 20060307
start_time: 0017
end_time: 0031

I've managed to form the tar file name based on these 3 elements in order to tar the 4 files mentioned into their specific tar files created.

However, I'd also need to include the element "SubNetwork=SE,SubNetwork=RNCABC,MeContext=RNCABC_statsfile" which is part of the original filename to the tar file name. This element of the filename is known as the Node_Id

To include the element to the tar file name, it has to be based on:
1) if the 3 elements i.e. , and are equal for a set of files, then use the Node_Id element of the file having the earliest of the timestamp within this category as one of the GROUPING criterias to bundle the individual files into the specific tar file. The tar file should also contain this particular Node_Id element.

2) if the 3 elements i.e. , and are not equal for a set of files, then just use the Node_Id element of the file having the earliest of the timestamp within this category to form the tar file name.

Could anyone help me out with this categorization within the script to include the Node_Id element to the tar file?

Thanks