HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
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.