I'm trying to get a bash script to search a text file in a certain folder and if it finds the number 192 in that file it then emails me the result of the grep. Script is as follows:
Code:
#!/bin/bash
PINGFILE="/home/tim/Documents/p5e/p5e_status/p5e_ping/*.txt"
if grep 192 $PINGFILE ; then
grep 192 $PINGFILE >> wfound.txt
ssmtp -vvv myemail@gmail.com < wfound.txt
fi
When I run the script it generates a file called wfound.txt fine with all the instances of 192. I also get an email OK, however there is nothing in it.
Where am I going wrong?
Many thanks
Tim