Linux: Find all soft links that link to a specific

2019-09-08 01:27发布

问题:

In Linux how do I find all soft links that link to a specific target directory or file?

回答1:

You could use find's -lname argument:

find . -lname linktarget


回答2:

Use find with -samefile and -L option, like this:

find -L -samefile TARGET


回答3:

What R1tschY sez, with an addition:

find -L -samefile TARGET \! -name TARGET

so TARGET won't be included in the result. (The backslash is required in bash so the ! won't be interpreted as a history directive.)