Venkataramesh Kommoju
Venkataramesh Kommoju

Reputation: 1099

List symbolic links and location, pointing to a particular directory

How to list all symbolic links that are pointing to a particular directory in Solaris?

I used find command on root directory and grep on top of it. This is extremely slow.

please suggest any other alternatives.

Upvotes: 2

Views: 18740

Answers (2)

Diego Torres Milano
Diego Torres Milano

Reputation: 69218

You can use this command, replace targetdir by the directory your are looking for:

TARGET=targetdir; find . -type l -exec ls -l {} \; | grep -- "-> $TARGET";

Upvotes: 3

martin clayton
martin clayton

Reputation: 78125

Symbolic links are uni-directional and 'entirely contained' in each link file - there's no separate list of links, or reverse link - you'll have to use find.

I presume you're using find / -type l to restrict 'find' to only report files that are symbolic links.

Have you restricted the search to eliminate areas that definitely won't contain links to your directory-in-question?

Upvotes: 2

Related Questions