i want to get the latest file from the directory ...
then extract the specific lines from it(the latest file which i extracted) starting from the charcters ...INSTANCEID ...Program started at.... program ended at ....
i want to do it for the multiple dirctories at the same time
You really did not provide much detail - examples of input and desired output. However, the following should get you started. See what you can write of a script, and post back follow-up questions.
Either of the following will give you the latest (most recent file). There are many ways to find this out, by the way.
> ls -lt | grep "^-" | head -1 | awk {'print $9'}
comp.log
> ls -lt | grep "^-" | head -1 | tr -s " " | cut -d" " -f9
comp.log
A script can then cat or head or grep on $file1
I would suggest trying to do this for one file. Once you can do that, it is farily easy to insert the command(s) into a loop function.
Command we tried using to grep ERROR from lastest 1 log files from 5 logs files available in that particular directory is:
grep ERROR 'ls -ltr | tail -1'
but this command is not working.. for me its saying.. cannot open DistributeImageFilesToTarget_10_dataLocations_PhillipinesDataLocations.xml.log
if i give ls -lrt for all the files in that diretory