home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!think.com!spool.mu.edu!umn.edu!csus.edu!nic.csu.net!nic.csu.net!nntp
- Newsgroups: comp.unix.shell
- Subject: Re: Find and symbolic links
- Message-ID: <1992Nov23.010350.3306@nic.csu.net>
- From: oleg@gd.cs.csufresno.edu
- Date: 23 Nov 92 01:03:49 PST
- Sender: oleg@gd.cs.csufresno.edu
- References: <1epg9qINNfb8@OPAL.SYSTEMSX.CS.YALE.EDU>
- Organization: Computer Science Departement of California State University in Fresno
- Nntp-Posting-Host: gd.cs.csufresno.edu
- Lines: 39
-
- In article <1epg9qINNfb8@OPAL.SYSTEMSX.CS.YALE.EDU> A. Satish Pai <Pai-Satish@CS.Yale.Edu> writes:
- >
- >Hi, everybody!
- >
- >Is there any workaround/trick/hack/shell-script that can be used to use find in
- >such a way that it follows symbolic links and descends down them recursively?
- >
- >I find it annoying that find doesn't follow links. No doubt there are good
- >reasons for making it operate that way but at least there should have been an
- >option to override that, IMHO. Why do I want to follow links? Out here, the
- >"real" directory structure is some hugely complicated thing that only the
- >sysadmins worry about; what users normally see (such as /usr/bin, /homes, etc.)
- >are almost all links to something else. I really don't want to run find with
- >arguments that look like /u6/old/tmp-sys/usr.bin when what I'm thinking of
- >is (say) /usr/bin. Naturally, if I just specify the names I want, find will
- >skip entire directories because something at the top happens to be a sym link.
- >
- The problem is that if someone in joe that has his home directory in /u6/home and
- does "ln -s pit .., your find will get /u6/home/joe/pit, /u6/home/joe/pit/joe/pit,
- etc. Unfortunately, "recursive" symlinks are sometimes on the system by default:
- look at /usr/kvm/sys/sun<smth>/machine on SunOS.
-
- One workaround is find /usr/bin/. , provided that there are no (interesting)
- symbolic links _under_ bin. Otherwize, you can write a shell script that tries to
- decend in symbolic links, like:
-
- #!/bin/sh
- if [ -d $1/. ]; then
- exec find $1/. -type s -o -type d -o -name $FINDNAME -exec $0 {} \;
- else
- echo $1 # Or whatever you want to do with it.
- fi
-
- Apparently there is no way to defeat ln -f foo ..
-
- Oleg
-
-
-
-