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?
awk(works if I replace withecho "$line") (you probably want to add a-type fto yourfindcommand to stopgrepthrowing errors and quote your"$line"variable but I don't think those things are your problem). Are you sure you copied your script here exactly??bash? Assuming you need loops at all it would make things quite a bit easier.