I'm building a bash script to send an email based off the last command. I seem to be having difficulties. Outside of a script the command works fine but when putting it in script it doesn't give the desired outcome.
Here is snippet of script:
grep -vFxf /path/to/first/file /path/to/second/file > /path/to/output/file.txt
if [ -s file.txt ] || echo "file is empty";
then
swaks -t "[email protected]" -f "[email protected]" --header "Subject: sample" --body "Empty"
else
swaks -t "[email protected]" -f "[email protected]" --header "subject: sample" --body "Not Empty"
fi
I ran the commands outside of script and I can see that there is data but when I add the commands within script I get the empty output. Please advise . Thank you in advance .
[ -s file.txt ]and/path/to/output/file.txtthe same? (you should always double-quote within[...]-- granted withfile.txtit makes no difference, but if it is a variable - double-quote) Please provide A Minimal, Complete, and Verifiable Example (MCVE).