SUMMARY:finding symlinks

From: Larry Chin (
Date: Fri Feb 28 1992 - 04:56:50 CST

Yesterday I asked:

> I hope this is not a FAQ or worse yet a question with an obvious answer
> Is there a way to do a find for symbolic links and only symbolic links?

Well it seems this was an obvious answer and I would have found it if
I had read the FM a little more carefully. My apologies for wasting

The answer is to use find with "-type l".

I have include the non-redundant replies below.

Thank you very much to those who took the time to answer this question.

Roger.Pease@Eng.Sun.COM ( Roger Pease x61353 )
wade@hobbes.UCSD.EDU (Wade Blomgren) (Rob McCool) (Roger Southwick) (Rob Quinn)
Barry Margolin <barmar@Think.COM>
mtm@CAMIS.Stanford.EDU (Mike Macgirvin) (Guy Harris)
rw@Rational.COM (Bob Weissman) (Charles H. Buchholtz)
Jay Plett <>


>From! Fri Feb 28 01:17:19 1992
Return-Path: <!>
Received: from by (4.1/SMI-4.1)
        id AA06630; Fri, 28 Feb 92 01:17:18 EST
Received: from Princeton.EDU ([]) by with SMTP id <53283>; Thu, 27 Feb 1992 23:13:03 -0500
Received: from by Princeton.EDU (5.65b/2.86/princeton)
        id AA08188; Thu, 27 Feb 92 23:12:52 -0500
Received: by (5.61/1.101)
        id AA08710; Thu, 27 Feb 92 22:51:06 -0500
Date: Thu, 27 Feb 1992 22:51:06 -0500

Message-Id: <>
Subject: Re: finding symbolic links
In-Reply-To: your article <>
News-Path: princeton!udel!!!ames!!usc!rpi!!torsqnt!jtsv16!cchtor!larry
Status: RO

Better than just save the names to a file, you can create a script which
will reconstruct them. Requires gnu find.

<rebus:jay> gfind /u/jay/Tmp -type l -printf 'ln -s %l %p' > reconstruct_links
<rebus:jay> cat reconstruct_links
ln -s foo /u/jay/Tmp/bar
ln -s /usr/local/bin /u/jay/Tmp/foobin
ln -s zzz /u/jay/Tmp/xxx
<rebus:jay> chmod 755 reconstruct_links



Finding symbolic links is easy with the find command.
Use the "-type l" option.

Example: find . -type l -print
or: find . -type l -exec ls -l {} \;

Both start search in the current dir.
The first prints equiv. of an "ls".
The second gives a more complete listing.


 find / -type l -exec ls -l {} \; > listoflinks.txt

should do what you want. As to parsing the output file and using it to
automagically rebuild the links, well, that's another story.


        find / -ls | grep " -> "


 Use 'find':
find . -type l -print | xargs ls -lg



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:37 CDT