Hello,
I have stucked at one point.
When I run the script, I am asking the script to search in database file and if it's found, do nothing and proceed to next line in database file.
#!/bin/bash
./extract_email.pl output2 > database
while read -r COL1
X=$(grep $COL1 database )
if [[ -z $X ]] ; then
echo "false"
exit
else
do
sed -n '1,2p' /var/test/test.txt > $COL1
sed -e '1,2d' /var/test/test.txt > /var/test/test2.txt
mail -s "mail subject is here" -a "From: info@mymail.net" $COL1 < $COL1
mv $COL1 /var/test/database_pool/
done < database
rm output*
rm *.host
exit 0
when i run the script, it says " syntax error near unexpected token `do' "
Could you please let me know how "do nothing" if col1 is already in my database.
You've got several syntactical and semantical errors, e.g.
while read; do ... done is not met
if ... fi is not met
mail ... $COL1 < $COL1 uses $COL as the URL and tries to read from it at the same time
But, in the first place, as Yoda pointed out, the entire if branch will never be executed as COL1 read from database will always be found in database ...
COL1 is not an important thing. I just want to know what and to whom I sent. For that reason, I keep sent mail record by the name of each recipient. Postfix is not configured exactly. Just spf record is okay.