home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / shell / 4840 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  2.2 KB

  1. 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
  2. Newsgroups: comp.unix.shell
  3. Subject: Re: Find and symbolic links
  4. Message-ID: <1992Nov23.010350.3306@nic.csu.net>
  5. From: oleg@gd.cs.csufresno.edu
  6. Date: 23 Nov 92 01:03:49 PST
  7. Sender: oleg@gd.cs.csufresno.edu
  8. References: <1epg9qINNfb8@OPAL.SYSTEMSX.CS.YALE.EDU>
  9. Organization: Computer Science Departement of California State University in Fresno
  10. Nntp-Posting-Host: gd.cs.csufresno.edu
  11. Lines: 39
  12.  
  13. In article <1epg9qINNfb8@OPAL.SYSTEMSX.CS.YALE.EDU> A. Satish Pai <Pai-Satish@CS.Yale.Edu> writes:
  14. >
  15. >Hi, everybody!
  16. >
  17. >Is there any workaround/trick/hack/shell-script that can be used to use find in
  18. >such a way that it follows symbolic links and descends down them recursively?
  19. >
  20. >I find it annoying that find doesn't follow links. No doubt there are good
  21. >reasons for making it operate that way but at least there should have been an
  22. >option to override that, IMHO. Why do I want to follow links? Out here, the
  23. >"real" directory structure is some hugely complicated thing that only the
  24. >sysadmins worry about; what users normally see (such as /usr/bin, /homes, etc.)
  25. >are almost all links to something else. I really don't want to run find with
  26. >arguments that look like /u6/old/tmp-sys/usr.bin when what I'm thinking of
  27. >is (say) /usr/bin. Naturally, if I just specify the names I want, find will
  28. >skip entire directories because something at the top happens to be a sym link.
  29. >
  30. The problem is that if someone in joe that has his home directory in /u6/home and
  31. does "ln -s pit .., your find will get /u6/home/joe/pit, /u6/home/joe/pit/joe/pit, 
  32. etc. Unfortunately, "recursive" symlinks are sometimes on the system by default:
  33. look at /usr/kvm/sys/sun<smth>/machine on SunOS. 
  34.  
  35. One workaround is find /usr/bin/. , provided that there are no (interesting)
  36. symbolic links _under_ bin. Otherwize, you can write a shell script that tries to
  37. decend in symbolic links, like:
  38.  
  39. #!/bin/sh
  40. if [ -d $1/. ]; then
  41.     exec find  $1/. -type s -o -type d -o -name $FINDNAME -exec $0 {} \;
  42. else
  43.     echo $1 # Or whatever you want to do with it.
  44. fi
  45.  
  46. Apparently there is no way to defeat ln -f foo ..
  47.  
  48. Oleg
  49.  
  50.  
  51.  
  52.