Checking for same file name

I was wondering if there is a way to to check if two files are the same. I've tried writing a script called samefile, which takes in two arguments (files) and attempts to compare them to see if they're the same file.

Here is what I have so far:

if [ $1 != $2 ]
then
echo "The two files are not the same!"
exit 1
elif [ $1 = $2 ]
echo "The two files are the same!"
exit 1
fi

Here's the output I'm getting:

samefile abc abc
-bash: test: abc: unary operator expected

That just checks the string, not the file, but it's not clear whether that's what you want.

I don't think you can put a ! inside single ['s like that, and you don't need to test twice.

if [ "$1" = "$2" ]
then
        echo "Strings are the same"
else
        echo "Strings differ"
fi

or

if ! [ "$1" = "$2" ]
then
        echo "Strings differ"
fi

By the way: You agreed not to spam the same topic across multiple forums when you registered.

Alright, your solution works perfectly. Thank you.

By the way: My bad.

My first thought is the diff command. See also this thread

This should provide a few ways to begin thinking about a solution.

Of course that really points some basic ideas to find solution.