SUMMARY:finding symlinks

From: Larry Chin (larry@cchtor.cch.com)
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
bandwidth.

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)
robm@ncsa.uiuc.edu (Rob McCool)
rogers@wrgate.wr.tek.com (Roger Southwick)
rjq@phys.ksu.edu (Rob Quinn)
Barry Margolin <barmar@Think.COM>
mtm@CAMIS.Stanford.EDU (Mike Macgirvin)
guy@auspex.com (Guy Harris)
rw@Rational.COM (Bob Weissman)
chip@eniac.seas.upenn.edu (Charles H. Buchholtz)
Jay Plett <jay@silence.princeton.nj.us>

----------------------------------------------------------------------

>From silence.princeton.nj.us!jay@uunet.ca Fri Feb 28 01:17:19 1992
Return-Path: <silence.princeton.nj.us!jay@uunet.ca>
Received: from uunet.ca by cch.com (4.1/SMI-4.1)
        id AA06630; Fri, 28 Feb 92 01:17:18 EST
Received: from Princeton.EDU ([128.112.128.1]) by mail.uunet.ca with SMTP id <53283>; Thu, 27 Feb 1992 23:13:03 -0500
Received: from silence.princeton.nj.us by Princeton.EDU (5.65b/2.86/princeton)
        id AA08188; Thu, 27 Feb 92 23:12:52 -0500
Received: by silence.princeton.nj.us (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: <9202280351.AA08710@silence.princeton.nj.us>
To: larry@cchtor.cch.com
Subject: Re: finding symbolic links
In-Reply-To: your article <1992Feb27.160105.4069@cchtor.cch.com>
News-Path: princeton!udel!darwin.sura.net!haven.umd.edu!ames!elroy.jpl.nasa.gov!usc!rpi!news-server.csri.toronto.edu!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

        ...jay

--------------------------------------------------------------------

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

----------------------------------------------------------------------

-- 
Thanks,



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