Diff command in bash -
every time run following bash command, error:
here's code:
sort -b ./tests/out/$scenario > $studentfile sort -b ./tests/out/$scenario > $proffile $(diff $studentfile $proffile) if [ $? -eq 0 ] echo "files equal!" else echo "files different!" fi
here's error:
./test.sh: 2c2: not found
i want sort 2 files, , check if equal or not. don't understand error means , how can rid of it. appreciated.
thanks!
short answer: use
diff $studentfile $proffile
instead of:
$(diff $studentfile $proffile)
long answer:
diff $studentfile $proffile
wil provide output of several lines, first one, in example, "2c2". if enclose diff command in $(), result of expression "2c2 ...". result taken bash new command, result of "command not found: 2c2".
compare, example:
$(diff $studentfile $proffile)
and:
echo $(diff $studentfile $proffile)
* addendum *
if diff $studentfile $proffile > /dev/null 2>&1 echo "equal files" else echo "different files" fi
Comments
Post a Comment