How to read from middle of a file for a particular text

Hi,

Below is my issue which I desperately need and I want a shell script which can do this job.

  1. There are 10 log files in a particular location.

  2. open each log file. Goto to the end of the file. From the end go up to find a particular text. From this particular text till the end of the log search for another particular text.

  3. if the particular text exists in the file return the file name(s) as the output.

Please help me with the script. Thanks a lot to all.

Thanks and Regards
Shriram

If it is not homework, please tell us why you need this type of code.

I m trying to prepare a system's health check during which certain text will be searched in the many logs under one location. Can you please let me know how to work it out.

I will refer to item 2 'particular text' as first keyword, and the ' another particular text' as second keyword.
Here is my script, works in ksh, should be good for bash or any other plain POSIX shell

 
KEYWRD1='your_first_keyword';
KEYWRD2='your_second_keyword'
 
# go through all log files in a particular directory: 
LOGDIR='your_log_directory_path'
# I don't know naming pattern of your logs, 
# for example they are ending with .log
 
for fn in $LOGDIR/*.log; do
#
# determine line number of last occurence of key word 1
#
  lineno=$( grep -n $KEYWRD1 $fn | tail -1 | cut -d':' -f1 )
#
# build ed command to print from that line to the end
#
  cmnd=$( printf "%d,$p" $lineno )
#
# run ed and grep throu the last n lines searching for KEYWRD2
#
  echo $cmnd | ed - $fn | grep -q $KEYWRD2
#
# if found (result 0) then spit out the file name
#
  if(( $? == 0 )); then
    echo $fn
  fi
done

I would think this could be reduced to a one-liner awk, but this is pure shell
I typed it into the browser window, hopefully no typos.