I'm trying to write an if statement that checks to see if two variables refer to the same file or directory. I can't simply compare the strings, because I want two different strings that refer to the same path.
For example, I would like to check if ./ and ../foobar/ refer to the same directory.
Simply doing test "$path1" -eq "$path2" won't work in some cases.
The answer is found in the documentation for the
testcommand:Here's an example:
Note that the two paths have to refer to a file or directory that exists. If
foobardoes not exist, thentest foobar -ef foobarwill evaluate to false.