System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

under a directory, what command to list all existing soft links?

SOLVED
Go to solution
Hanry Zhou
Super Advisor

under a directory, what command to list all existing soft links?

Thanks!
none
3 REPLIES
Patrick Wallek
Honored Contributor
Solution

Re: under a directory, what command to list all existing soft links?

find . -type l -exec ls -ld {} +
James R. Ferguson
Acclaimed Contributor

Re: under a directory, what command to list all existing soft links?

Hi Hanry:

While Patrick has answered your query for _symbolic_ links, for completeness to list _hard_ links, do:

# find . -type f -links +1 -exec ls -lid {} +|sort -kn1,1

This lists all files with more than one hardlink. The listing is sorted by the inode number.

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: under a directory, what command to list all existing soft links?

How _far_ "under a directory"? Unless you
stop it, "find" will search all
subdirectories recursively.

There's something to be said for a simple
method:

ls -l | grep '^l'

But, as usual, the right answer may depend on
details which are missing from the problem
as stated.