in reply to Dereference a filesystem path with softlinks

I think the only way to determine if two paths (that could include soft links) point to the same directory is to do a @arr=stat("$path/."), take the inode number ($arr[1] in this case), and compare those.

If the paths point to the same inode number, it's the same directory. If they don't, it isn't.

Replies are listed 'Best First'.
Re: Re: Dereference a filesystem path with softlinks
by Fletch (Bishop) on Apr 20, 2004 at 19:45 UTC

    Unless of course it's two different directories on different devices which just happen to have the same inode number . . .

    $ df -k | head -3; perl -le 'print"$_:\t".(stat $_)[1]for@ARGV' / /dev + Filesystem 1K-blocks Used Avail Capacity Mounted +on /dev/disk0s9 58598824 39199392 19143432 67% / devfs 96 96 0 100% /dev /: 2 /dev: 2

    Update: To elaborate, you want to use the tuple (device number, inode number), not just inode number.