I\'d like to create a script that greps for a specific string in a log file that is being written to. I\'d like to take the first result and put that into a variable for lat
Thank you all for the input. You helped figure out a better way to do it, using while and tail without -f
werd=$1
var=""
while [ "${var}" == "" ]
do
var=$(tail -1 /var/log/named.log | grep "${werd}");
done
echo "${var}";
This just reads the last line in the file. Since the file is being written to, the last line changes which is the result I was looking for.