SH/BASH - Scan a log file until some text occurs, then exit. How??
- by James
Current working environment is OSX 10.4.11.
My current script:
#!/bin/sh
tail -f log.txt | while read line
do
if echo $line | grep -q 'LOL CANDY'; then
echo 'LOL MATCH FOUND'
exit 0
fi
done
It works properly the first time, but on the second run and beyond it takes 2 occurrences of 'LOL CANDY' to appear before the script will…