Operating System - HP-UX
1827318 Members
5488 Online
109961 Solutions
New Discussion

need to find all symbolic links starting at a particular directory

 
SOLVED
Go to solution
Unix Administrator_5
Frequent Advisor

need to find all symbolic links starting at a particular directory

I need to find all the symbolic links starting at a particular directory.

I tried find . -type l -follow
but it doesnt seem to descend the hierarchy.
6 REPLIES 6
Uday_S_Ankolekar
Honored Contributor

Re: need to find all symbolic links starting at a particular directory

ls -al | grep ^l

-USA..

Good Luck..
Paul Sperry
Honored Contributor

Re: need to find all symbolic links starting at a particular directory

# find . -type l | xargs ll -d
Pete Randall
Outstanding Contributor

Re: need to find all symbolic links starting at a particular directory

You don't want the -follow:

-follow A position-independent term which causes find
to follow symbolic links. When following
symbolic links, find keeps track of the
directories visited so that it can detect
infinite loops; for example, such a loop
would occur if a symbolic link pointed to an
ancestor. This expression should not be used
with the -type l expression. Always true.



Pete

Pete
Hai Nguyen_1
Honored Contributor

Re: need to find all symbolic links starting at a particular directory

Try this:

# find . | xargs ll -d | grep '^l'

Hai
Jeff Schussele
Honored Contributor
Solution

Re: need to find all symbolic links starting at a particular directory

Hi,

Just use

find /start_dir -type l -exec ll {} \;

Or you can exec any command you want.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Elena Leontieva
Esteemed Contributor

Re: need to find all symbolic links starting at a particular directory

Another way to do it is:

find /dirname -type l -exec ls -l {} \;

Elena.