home *** CD-ROM | disk | FTP | other *** search
- From: istvan@hhb.UUCP (Istvan Mohos)
- Newsgroups: alt.sources
- Subject: directory clusters
- Message-ID: <318@hhb.UUCP>
- Date: 6 Mar 90 16:07:13 GMT
-
-
- A very nice utility, in perl, posted by jv@squirrel.mh.nl (Johan Vromans).
- Here is a somewhat crude, C shell version.
-
- ==============================CUT HERE====================================
- #! /bin/csh -f
- # lndir --- original in perl, by Johan Vromans
- # C shell version by Istvan Mohos, 03/06/90
- # change '/dev/null &&' to '/dev/null ||' for System III, XENIX
-
- set PROG = $0
- # if source or target directory not specified, print usage and exit
- if ($#argv < 2) then
- usage:
- echo "Usage: $PROG:t <sourcedir> <targetdir>\
- to replace each <targetdir> file that exactly matches same-name\
- file in <sourcedir>, with a hard link to file in <sourcedir>."
- exit 1
- endif
-
- # verify that directories exist
- if (! -d $argv[1] || ! -d $argv[2]) goto usage
-
- # diff files
- foreach file ($argv[1]/.[+-z]* $argv[1]/*)
- if (-f $file) then
- set EGO = $file:t
- set INODE1 = `/bin/ls -i $file`
- set INODE2 = `/bin/ls -i $argv[2]/$EGO`
- if ($INODE1[1] != $INODE2[1]) then
- /bin/cmp $file $argv[2]/$EGO >& /dev/null && \
- (/bin/rm -f $argv[2]/$EGO; /bin/ln $file $argv[2]; \
- echo linking $EGO)
- endif
- endif
- end
- exit 0
- --
- Istvan Mohos
- ...uunet!pyrdc!pyrnj!hhb!istvan
- RACAL-REDAC/HHB 1000 Wyckoff Ave. Mahwah NJ 07430 201-848-8000
- ======================================================================
-