I have a directory '/opt/storage/logdir' where a bunch of logs files
are written everyday(.log files)
How do I write a script that runs everyday and looks for the previous day's log files, searches for the
word 'HALTED' in yesterday's files and then emails the contents of that particular file
to a specified email Id ?
-rw-r----- 1 user group 23456334 Apr 26 15:01 4343.log
-rw-r----- 1 user group 896765 May 24 15:59 3221.log
-rw-r----- 1 user group 22151186 May 25 16:59 4632.log
If this script runs on May 25th, it needs to search for the word 'HALTED' in 3221.log
and if found, email the contents of 3221.log with the subject 'HALTED found in 3221.log' ?
I looked at it again. On second thoughts, if it can just print the subsequent lines (after the HALTED) until it finds a whole blank line, that is fine(rather than the whole file)
For example :if the contents of the log file are --------
overcome:work Action:"Halted" Code :0 aaaaaaaaaaaaaaa