Thanks for the reply. Sorry if i am not clear here.
suppose file1 is as follow ( and other files file2, file3 etc also similar to this, only data is different)
00020856820000 00544 00000000000001028
00068826707655 00155 00000000000006013
00003150631309 00166 00000000000002027
00004800121348 00088 00000000000004042
00068826704470 00645 00000000000001101
00001380055665 06005 00000000000001045
00078616200151 00603 00000000000004014
00002880015010 06111 00000000000001099
00004400002795 00603 00000000000006142
00002073511018 06078 00000000000004044
00002073509273 06078 00000000000001024
00000000004329 00144 00000000000002133
00004152087031 00666 00000000000001080
00004470000927 00777 00000000000001106
00002310010266 00066 00000000000002129
00001251140600 00650 00000000000001116
00004180050130 00666 00000000000002036
00007218056750 00444 00000000000002049
00068826712549 00650 00000000000001027
00004140900410 00767 00000000000002134
dir1, dir2, dir3,dir4 contain the logs, log1.txt,log2.txt,log3.txt
log1.txt is inside dir1
log2.txt is inside dir2
log3.txt is inside dir3
log4.txt is inside dir4
dir1,dir2,dir3 etc names are always like this, i.e always word "dir" comes at the starting in directory name.
suppose log1.txt is
00068826707655 sfdfsdfsf
00003150631309 gdgdgdgdg
00004800121348 sgsgsgsgsg
log2.txt is
00004400002795 gsgsgsgsgsg
00002073511018 gsgsggsgsgg
log3.txt is
00007218056750 gsgsgsgsg
00068826712549 gsgsgsgsg
00004140900410 gsgggsgsg
log4.txt is
00001251140600 fasdfasfs
so i am thinking like:
1) Traverse file xyz.txt
2) First, read file1, store the filename(file1) in some variable
3) Traverse through dir1,dir2,dir3,dir4 and cut the first field from 1-14 ( only the numbers) from the logs log1.txt, log2.txt, log3.txt, log4.txt i.e.
00068826707655
00003150631309
00004800121348
00004400002795
00002073511018
00007218056750
00068826712549
00004140900410
00001251140600
4) grep these numbers from the file1 and make a new file.
00068826707655 00155 00000000000006013
00003150631309 00166 00000000000002027
00004800121348 00088 00000000000004042
00004400002795 00603 00000000000006142
00002073511018 06078 00000000000004044
00007218056750 00444 00000000000002049
00068826712549 00650 00000000000001027
00004140900410 00767 00000000000002134
5) Then, repeat the same steps from 2) to 4) for file2
6) Then, repeat the same steps from 2) to 4) for file3