I'm getting unexpected results from the following
COMPARE(){
if [ ! cmp $IPPATH/ip.old $IPPATH/ip.new >/dev/null 2>&1 ]; then
echo compare going to create
CREATE
else
echo same
fi
}
I'm trying to compare the files, if they're the same, do nothing (i.e. display same
, but if they're NOT the same then display compare going to create
and then run the CREATE
function.
However, I get the same "same
" result when the file are identical and when they are definitely NOT the same.
these display correctly (as they should):
echo `cat $IPPATH/ip.old`
echo `cat $IPPATH/ip.new`
[
operator accepts a restricted set of conditions, not full shell commands. Aside from that, your code is fine; just remove the[
and]
characters. – Mark Plotnick Sep 05 '16 at 16:50