Operating System - HP-UX
1752755 Members
5088 Online
108789 Solutions
New Discussion юеВ

Re: 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 3
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.