Can anyone help me out to figuring what is wrong with this program?
#!/bin/bash
find teste1 > names.lst
find teste2 > names2.lst
result=$(diff -y -W 72 $names $names2)
if [ $? -eq 0]; then
echo "files are the same"
else
echo "files are different"
echo "$result"
fi
It returns the following errors:
diff: missing operand
teste.sh: [: missing ']'
Files are different
(a blank space appears here)
The blank space is the variable "result" but why did it not save the differences between the 2 files?
I am trying to use diff to find out the differences in the texts on both those files.
$names, $names2? I assume those are intended to benames.lst, names2.lstbut this code does not set the variables.