Operating System - HP-UX
1756397 Members
3255 Online
108847 Solutions
New Discussion юеВ

Re: Searching for sym-links to a filesystem

 
SOLVED
Go to solution
Chern Jian Leaw
Regular Advisor

Searching for sym-links to a filesystem

HI,

I have a filesystem i.e /fs10/patterns/design.
Is there a way to search for the name of the symbolic link which is pointing TO /fs10/patterns/design?

Could someone please show me how it's done?

Thanks.
6 REPLIES 6
Michael Tully
Honored Contributor

Re: Searching for sym-links to a filesystem

Not sure what your filesystem name is that your trying to find... but here is how to find all symbolic links within a filesystem.

# cd /fs10/patterns/design
# find . -xdev -type l -print | xargs ll

If there are too many you could output his to a file.

# find . -xdev -type l -print | xargs ll >/tmp/wrk
Anyone for a Mutiny ?
Bill Hassell
Honored Contributor

Re: Searching for sym-links to a filesystem

A symlink is a 1-way link. It is created (somewhere) and points to your file or directory. There is no connection going the other way. So you'll have to use find, look just for symlinks, then use the ll to shown where the link is pointing and grep for the directory you are looking for:

find / -type s -exec ll {} \; | grep /fs10/patterns/design


Bill Hassell, sysadmin
Chern Jian Leaw
Regular Advisor

Re: Searching for sym-links to a filesystem

Bill,
Your suggestion of:
find / -type l -exec || {}\;|grep /fs10/patterns/design
produced the following error:
An expression term lacks a required parameter.

I tried also on using:
find /fs36 -type l -exec grep /fs10/patterns/design {}\;
which takes a long time to produce the results.

Could you tell me how it should have been done?

Thanks.
Chern Jian Leaw
Regular Advisor

Re: Searching for sym-links to a filesystem

Michael,

I'm trying to find search for the sym-link name which is pointing to the original data i.e: /fs10/patterns/design.

The method which you showed seemed to only work for searching for links within /fs10/patterns/design.

I would like to search for links TO /fs10/patterns/design.

Could you help me out?

Thanks.
Michael Tully
Honored Contributor
Solution

Re: Searching for sym-links to a filesystem

Try it this way, using 'xargs' instead of '-exec' should be more efficient.

find /fs36 -type l | xargs grep /fs10/patterns/design
Anyone for a Mutiny ?
Frank Slootweg
Honored Contributor

Re: Searching for sym-links to a filesystem

> Bill,
> Your suggestion of:
> find / -type l -exec || {}\;|grep /fs10/patterns/design
> produced the following error:
> An expression term lacks a required parameter.

Please look very closely at Bill's example. I.e. your posting contained several errors, not only pipe-symbols instead of ells ("l", lower-case L), but also missing spaces. The find syntax, especially for "-exec ..." is *very* precise, i.e. spaces *do* matter.

But yes, the parameter for the "-type" option should be "l" (ell, lower-case "L"), not "s". :-)