rajesh kumar wrote:
Hi,
I wish to compare tree stucures of two directories. that is to
compare the subdirectories as well as their subdirectories and so
on...only directories and subdirectories and their subdirectories. I
am not interested about their contnets like files.
I am working on Solaris:
Here is the code which I prepared but it is not giving the appropriate
results, Can any one help me in finding out the changes to eb made so
that I can get the required output.
code is-----------------------
#! /bin/sh
#
#
#
# function for comparing directories
#----------------------------function
compare()--------------------------------------------
compare(){
echo "in compare function: "
if [ -d $1 -a -d $2 ];
then
comparedir $1 $2
else
echo "type mismatch: $1 and $2"
false
fi
return
}
#
#-----------------------------Function
comparedir()------------------------------------------
#
comparedir()
{
result=0
echo "compare fdir function:"
for i in `(ls -A $1 && ls -A $2)|sort|uniq`; do
compare $1/$i $2/$i || result=1
done
return $result
}
#
#
#--------------------------------Main script starts
here---------------------------------------
bool=true
while($bool)
do
echo "enter the standard directory with which comparision to
be done: \c"
read dir1
if [ -d $dir1 ]; then
bool=false
else
echo "$dir1 does not exists; enter valid directory name."
bool=true
fi
if [ $bool = false ]; then
echo "enter the directory to be compared: \c"
read dir2
if [ -d $dir2 ]; then
bool=false
else
echo "$dir2 does not exists; enter valid directory name."
bool=true
fi
fi
done
compare $dir1 $dir2
i=echo "$?"
if [ $i -eq 0 ];
then
echo "directory tree structures are same!!!!!!!!!!!"
else
echo "directory tree structures are not same????"
fi
exit 1
-------------------------------------------------
Thanks in advance
Rajesh
------------------------------------------------------------------------
Yahoo! FareChase - Search multiple travel sites in one click.
<http://us.lrd.yahoo.com/_ylc=X3oDMTFqODRtdXQ4BF9TAzMyOTc1MDIEX3MDOTY2ODgxNjkEcG9zAzEEc2VjA21haWwtZm9vdGVyBHNsawNmYw--/SIG=110oav78o/**http%3a//farechase.yahoo.com/>
Couldnt you use rsync -n? It displays what would have ben transfered (ie
the differences). To my knowledge, rsync is available for SUN, and if
not, you can always compile it:)
Regards,
YH
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]