-1
echo"enter first file"
read file
echo"enter second file"
read file1
if [-f $ file]
then
    if[-f $file1]
    then
        cmp $file $file1
        if [$? -eq u]
        then rm $file1
            echo"both are same"
            echo"deleted second file"
        else
            echo"files are not similar"
        fi
    fi
fi
  1. List item
ashu56
  • 9

1 Answers1

1

It is very important to be careful about blank space between words in shell scripts. The problem with [ was already mentioned in the comments, but you have some other problems, too - the $ file and also echo"stuff with no space.

Also, you have some other problems. In case the filename contains a space, you should use quotes with all "$variable" references. I don't know why you thought u would work in if [$? -eq u] - the value will be 0, not u.

Random832
  • 1,155