[: <filename>: unexpected error in shell programming

view story

http://stackoverflow.com – I have created a script which creates two files and reverses their contents if both the files are different. I cant understand how to resolve this error : [: my-filename: unexpected error in shell programming Code: echo "Enter first filename :" read file1 echo "Enter second filename:" read file2 echo "Enter content of file 1 : " gedit $file1 echo "Enter content of file 2 : " gedit $file2 check=" " x=` cmp $file1 $file2 ` if [ $x -eq $check ] then echo "Both files are same" rm $file2 echo "Redundant file removed!!!" else echo "They are different" fi tac $file1 | cat > temp1 rev te (HowTos)