home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
0
/
0994
< prev
next >
Wrap
Internet Message Format
|
1990-12-28
|
2KB
From: istvan@hhb.UUCP (Istvan Mohos)
Newsgroups: alt.sources
Subject: directory clusters
Message-ID: <319@hhb.UUCP>
Date: 7 Mar 90 14:08:42 GMT
A very nice utility, in perl, posted by jv@squirrel.mh.nl (Johan Vromans).
Here is a recursive C shell version.
==============================CUT HERE====================================
#! /bin/csh -f
# lndir --- original in perl, by Johan Vromans
# Recursive C shell version by Istvan Mohos, 03/07/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
echo "Usage: $PROG:t <sourcedir> <targetdir>\
to replace each exact <targetdir> copy of <sourcedir> files\
with a hard link from <targetdir> to the <sourcedir> file."
exit 1
endif
# verify that directories exist
if (! -d $argv[1] || ! -d $argv[2]) exit 0
echo $PROG:t $argv[1] $argv[2]
# compare same size files if inodes are different
foreach file ($argv[1]/.[+--]* $argv[1]/.[0-z]* $argv[1]/*)
set EGO = $file:t
if (-f $file) then
if (-f $argv[2]/$EGO) then
set F1 = `/bin/ls -li $file`
set F2 = `/bin/ls -li $argv[2]/$EGO`
if (($F1[1] != $F2[1]) && ($F1[5] == $F2[5])) 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
else
$0 $file $argv[2]/$EGO
endif
end
exit 0
--
Istvan Mohos
...uunet!pyrdc!pyrnj!hhb!istvan
RACAL-REDAC/HHB 1000 Wyckoff Ave. Mahwah NJ 07430 201-848-8000
======================================================================