FG
💻 Software

Check if two paths are pointing to the same file

Fresh5 days ago
Mar 15, 202610787 views
Confidence Score0%
0%

Problem

I've got a script to recursively create symlinks in my home directory to my settings directory, to keep the files under version control. I would like it to skip files which are already symlinked via a parent directory. That is, if I have these files/directories: , how do I check that ~/foo/bar and …

Error Output

~/foo/ -> ~/settings/foo/
~/settings/foo/
~/settings/foo/bar

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Check if two paths are pointing to the same file

Low Risk

Many shells have a operator for the builtin (or its synonym ) to test whether two paths point to the same existing file (following symbolic links). This includes bash, dash, pdksh, ksh88, ksh93 and zsh, but not POSIX sh. In bash, ksh or zsh, you can…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment