1840378 Members
2527 Online
110164 Solutions
New Discussion

script

 
Tonatiuh
Super Advisor

script

Red Hat Enterprise Linux 3

I want to know how to create a script which check if certain file, has certain string, and if find that string that writes a log (another file) appening this string and the date-time which was done.

Any idea about how?
1 REPLY 1
Ivan Ferreira
Honored Contributor

Re: script

Usage: script string_to_search file_to_search


LOGFILE=/tmp/logfile.log
FOUND=`grep $1 $2 |wc -l`

if [ $FOUND -gt 0 ]; then
echo $1 >> /tmp/logfile.log
date >> /tmp/logfile.
fi
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?