How can I check for a string match AND an empty file in the same if/then bash script statement?
- by Mike B
I'm writing a simple bash script to do the following:
1) Check two files (foo1 and foo2).
2) If foo1 is different from foo2 and foo1 NOT blank, send an email.
3) If foo1 is the same as foo2... or foo1 is blank... do nothing.
The blank condition is what's confusing me. Here's what I've got to start with:
diff --brief <(sort ./foo1) <(sort ./foo2) >/dev/null
comp_value=$?
if [ $comp_value -ne 0 ]
then
mail -s "Alert" [email protected] <./alertfoo
fi
Obviously this doesn't check for blank contents. Any thoughts on how to do that?