I have ~750 log directories I need to search for the latest log file available:
These are captured by the allLogs.txt file and each entry contains a wild card '*' so that ONLY the log with the latest date is grabbed (there can be many logs of the same name with different dates. e.g.
import_Asbeg_DA_Config3_*.log
import_test_deploy_*.log
import_Plus_DQ_Config1_*.log
e.g. I know this is not pretty but it works great to accomplish the goal in a loop.
for LATEST in `cat allLogs.txt` ;
do
find -name "${LATEST}" -type f | sort -n | tail -1
done < infile > outfile
This finds ~350 records because all the directories might not have a log file.
"allLogs.txt" contains all the ~750 paths to the log file for that directory.
What I am trying to figure out how to run this command in my loop BUT, maintain consistency even if no log file is found. Perhaps by appending 'INVALID' to the records that DO NOT contain a log file. I've tried combinations of echo with the find command but no luck. Any ideas?