If Not Diff statement in ksh 88

Hi
I tried the below code where it is working properly

#!/bin/ksh
set -x
date1_data=abc.txt
date2_data=bcd.txt
if diff $date1_data $date2_data >/dev/null ; then
   echo "Equal"
else
   echo "Not Equal"
  fi

Then I tried like below where i want to use only if fi not else part

#!/bin/ksh
set -x
date1_data=abc.txt
date2_data=bcd.txt
if not diff $date1_data $date2_data >/dev/null ; then
   echo "NotEqual"
  fi

The above code is giving the error saying

not: not found

Please advice me where the script is wrong

there is no not command in ksh. try ! or test

1 Like

diff returns 0 when no differences are found, 1 when there are differences, >1 (2,3,4...)
when there was an error.

Probably the best usage is to cover all possibilities by looking for all the return values.
simple example:

diff filea fileb > /dev/null
rc=$?
[ $rc > 1 ] && echo 'fatal error'  && exit 1
[ $rc -eq 0 ] && echo 'same'
[ $rc -eq 1] && echo 'different'
1 Like

Try

diff file1 file2 || echo "not equal"