0
find . -name 'Email*.log' -exec grep -il 'bad password' {} \;| while read line; do
  TEMPNUM=`tail -20 $line | grep 'bad password' | wc -l`
  if [ $TEMPNUM -gt 0 ]; then
     awk '/Username/{print $NF}' $line >> expiredmailbox.txt
  fi
done

This is the code I used and ran the shell script. I am getting
line 6: syntax error near unexpected token `done' Even if just try to echo the $line. I am getting an error. How can I eliminate this?

Kamaraj
  • 4,365

1 Answers1

-1

can you try this..

#!/bin/bash

find . -name 'Email*.log' | xargs grep -li  'bad password' |  while read line
do
  TEMPNUM=$(tail -20 "${line}" | grep -c 'bad password')
  if [ "${TEMPNUM}" -gt "0" ]; then
     awk '/Username/{print $NF}' "${line}" >> expiredmailbox.txt
  fi
done
Kamaraj
  • 4,365