Find all symbolic links pointing to a file
iMac, Mac OS X (10.6.4), 3.2 GHz Intel Core i3, 4 GB RAM
iMac, Mac OS X (10.6.4), 3.2 GHz Intel Core i3, 4 GB RAM
BobHarris wrote:
Nothing wrong with your approach, and as shown above it would be a bit more efficient, and most likely the few false positives are noise (unless the name was not very unique).
However, since the OP (GaryKing) has not checked in since his first post, we do not know any more details on his needs. Whether good enough is all he wants, or if accuracy is important.
sudo time find / -type l -ls | fgrep "test.txt"
...
238.97 real 3.81 user 51.58 sys
sudo time find / -type l -exec test {} -ef "test.txt" ; -print
...
243.92 real 8.71 user 71.88 sys
...running another shell with 'test' can only be inefficient
Why would there be any false positives?
Are you referring to my 'shortcut' of a partial file name?
If so, only need to fgrep the full path and filename and only that file will be filtered.
ln -s ../../bin/fred.real my.symlink.name
ln -s /Users/harris/bin/fred.read my.other.symlink
ln /Users/harris/bin/fred.read fred.hardlink
ln -s fred.hardlink my.alternate.symlink
BobHarris wrote:
Also a symlink can point to another symlink and still get to the real file, you would not see that with a find -ls.
corbaguy wrote:
From the command line:
find / -type l -exec test {} -ef /path/to/file \; -print
Find all symbolic links pointing to a file