Skip to content
Advertisement

How to find all symlinks to a file?

This is my hierarchy:

JavaScript

l1 and l2 are symlinks to a.txt. I run this code to find all symlinks to a.txt in the /aaaaaaaa:

JavaScript

And it obviously doesn’t work, cause I must compare realpath of file with path of a.txt. In what way I should do this?

Advertisement

Answer

If you have GNU/BSD find just use -samefile primary.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement