Here is expected output:-
For each file with following file name pattern we need to look at position 1 inside first file matching our search criteria if first letter of the line is 5 then position 88-94 will be 0000001 then look for line immediately after 5 which starts with i.e. position 1 = 8 then position 88-94 will be 0000001 for that line starting with 8. Now again look first line start with 5, if matches then set position 88-94 will be 0000002. Now again look for line starting with 8 and set position 88-94 will be 0000002. Process this untill end of First file. Now assume last occurrence of line starting with 8 have position 88-94 = 0000010 then Look for occurrence of 5 in position 1 inside Second file If found then set position 88-94 will be 0000011, Also find line staring with 8 immediately and set position 88-94 will be 0000011.Continue numbering this until we are done with file matching our file search criteria.
Expected Output:-
File 1 name = ABCDEFG1234567_mm-dd-yy_hh_mm_ss123.data
Position:- 1234567890..............................................94
101 101000048 CITY ABCDEF FILE BC TOMJE
5220ABCDEF PQRSTUVWX 2342342345PPDAB 0000001
101 101000048 CITY ABCDEF FILE BC TOMJE 12
8220000005005550001000000000000 0000001
5225ABCDEF PQRSTUVWX 121029080319303110 0000002
11 101000048 CITY ABCDEF FILE BC TOMJE 13
820000005005550001000000000000 0000002
File 2 name = ABCDEFG1234567_mm-dd-yy_hh_mm_ss145.data
Position:- 1234567890..............................................94
101 101000048 CITY ABCDEF FILE BC TOMJE
5220ABCDEF PQRSTUVWX 2342342345PPDAB 0000003
101 101000048 CITY ABCDEF FILE BC TOMJE 12
8220000005005550001000000000000 0000003
5225ABCDEF PQRSTUVWX 121029080319303110 0000004
11 101000048 CITY ABCDEF FILE BC TOMJE 13
820000005005550001000000000000 0000004
File 3 name = ABCDEFG1234567_mm-dd-yy_hh_mm_ss167.data
Position:- 1234567890..............................................94
101 101000048 CITY ABCDEF FILE BC TOMJE
5220ABCDEF PQRSTUVWX 2342342345PPDAB 0000005
101 101000048 CITY ABCDEF FILE BC TOMJE 12
8220000005005550001000000000000 0000005
5225ABCDEF PQRSTUVWX 121029080319303110 0000006
11 101000048 CITY ABCDEF FILE BC TOMJE 13
820000005005550001000000000000 0000006
File 4 name = ABCDEFG1234567_mm-dd-yy_hh_mm_ss189.data
Position:- 1234567890..............................................94
101 101000048 CITY ABCDEF FILE BC TOMJE
5220ABCDEF PQRSTUVWX 2342342345PPDAB 0000007
101 101000048 CITY ABCDEF FILE BC TOMJE 12
8220000005005550001000000000000 0000007
5225ABCDEF PQRSTUVWX 121029080319303110 0000008
11 101000048 CITY ABCDEF FILE BC TOMJE 13
820000005005550001000000000000 0000008
Here is the Code which find the files matching criteria:-
TS=`date +"%m-%d-%Y"`| for fname in `find . -name "ABCJmdmfbsjop???????_${TS}*.data"`
do # Matching File Processing Code.