1

HP-UX ***B.11.31 U ia64 ***** unlimited-user license.

$ ls -al
10 May  9  2011 HORCM -> /opt/HORCM
8 May  9  2011 bin -> /usr/bin
0 Mar 29  2012 core
Feb 18 05:36 dev

How do I list the link name and link location (where the link resides), when I know the directory where the link takes me to? I would like to know this for links to directories only. That is the reason I pasted only directories (HORCM is a directory) in the code above.

1
  • using the find command, but yes, you would have to search through all the potential places. sudo find / -name HORCM -type l -ls would search the entire filesystem
    – bsd
    Commented Feb 27, 2015 at 10:27

2 Answers 2

2

As the other answer states, there is no simple task to do that. You have to search the whole filesystem. Here is an approach:

find / -type l -ls 2>/dev/null | grep -P " -> .*HORCM$"

It uses find to search all links, then prints them in a form like ls -dils. At the end, the complete output is grepped for the folder you search. It may take a while to search trough the system.

1

There's no way of knowing what symbolic links exist that point to a particular directory or whatever, besides simply searching through the entire filesystem for symbolic links and checking what those links point to.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .