Hi,
I am new to Unix shell scripting, starting to learn it. Can you please help me with this immediate requirement to code.. The requirement is as given below.
In a directory say Y, I have files like this.
PP_100000_28062006_122731_746.dat
PP_100000_28062006_122731_745.dat
PP_100000_28062006_122734_745.dat
PP_100000_28062006_122732_745.dat
PP_100000_28062006_122801_745.dat
QQ_100001_28062006_122733_745.dat
QQ_100001_28062006_122731_745.dat
RR_100002_28062006_122731_745.dat
RR_100002_28062006_122731_745.dat
RR_100002_28062006_122731_745.dat
format: <type>_<somesequence>_DDMMYYYY_HHMMSS_<organisationID>
Now, I will have an input parameter coming in as 'Directory path' (path to Y) and type (can be PP, QQ or RR. If type is NULL, means I need to process all the 3 types)
Assuming we get type as PP
Now I need to pick up files of this type. We can see there are 5 files matching this string.
Now, I need to check the date and time stamp as available in the file names (and not the unix system date timestamp), compare it, and pick up the file with the lowest date timestamp in its name, first - and process it.
As you see I have 2 files with same timestamp here - PP_100000_28062006_122731_746.dat and PP_100000_28062006_122731_745.dat. In this case I have to process it in ascending order of <organisationID>. ie, PP_100000_28062006_122731_745.dat first, followed by PP_100000_28062006_122731_746.dat
Once processed, I have to pick the next lowest date time stamp file for processing.
I will be archiving successfully processed files in another directory, and renaming failed files to say FAILED (suffix) so that it wont be picked up again.
Any sample code/ pointers/ suggestions would be of great help.
Thanks a lot in advance,
Chindhu