home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 0 / 0985 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  1.5 KB

  1. From: istvan@hhb.UUCP (Istvan Mohos)
  2. Newsgroups: alt.sources
  3. Subject: directory clusters
  4. Message-ID: <318@hhb.UUCP>
  5. Date: 6 Mar 90 16:07:13 GMT
  6.  
  7.  
  8. A very nice utility, in perl, posted by jv@squirrel.mh.nl (Johan Vromans).
  9. Here is a somewhat crude, C shell version.
  10.  
  11. ==============================CUT HERE====================================
  12. #! /bin/csh -f
  13. # lndir --- original in perl, by Johan Vromans
  14. # C shell version by Istvan Mohos, 03/06/90
  15. # change '/dev/null &&' to '/dev/null ||' for System III, XENIX
  16.  
  17. set PROG = $0
  18. # if source or target directory not specified, print usage and exit
  19. if ($#argv < 2) then
  20.     usage:
  21.     echo "Usage: $PROG:t <sourcedir> <targetdir>\
  22.     to replace each <targetdir> file that exactly matches same-name\
  23.     file in <sourcedir>, with a hard link to file in <sourcedir>."
  24.     exit 1
  25. endif
  26.  
  27. # verify that directories exist
  28. if (! -d $argv[1] || ! -d $argv[2]) goto usage
  29.  
  30. # diff files
  31. foreach file ($argv[1]/.[+-z]* $argv[1]/*)
  32.     if (-f $file) then
  33.         set EGO = $file:t
  34.         set INODE1 = `/bin/ls -i $file`
  35.         set INODE2 = `/bin/ls -i $argv[2]/$EGO`
  36.         if ($INODE1[1] != $INODE2[1]) then
  37.             /bin/cmp $file $argv[2]/$EGO >& /dev/null && \
  38.             (/bin/rm -f $argv[2]/$EGO; /bin/ln $file $argv[2]; \
  39.             echo linking $EGO)
  40.         endif
  41.     endif
  42. end
  43. exit 0
  44. -- 
  45.         Istvan Mohos
  46.         ...uunet!pyrdc!pyrnj!hhb!istvan
  47.         RACAL-REDAC/HHB 1000 Wyckoff Ave. Mahwah NJ 07430 201-848-8000
  48. ======================================================================
  49.