LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Closed Thread
  Search this Thread
Old 11-02-2005, 06:53 AM   #1
raj_thota
LQ Newbie
 
Registered: Nov 2005
Location: Pune
Posts: 4

Rep: Reputation: 0
Help: regarding comparing two directory tree structures


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
 
Old 11-02-2005, 07:16 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help: regarding comparing two directory tree structures raj_thota Linux - Software 2 11-02-2005 12:19 PM
hel: regarding comparing two directory tree structures raj_thota Programming 1 11-02-2005 07:16 AM
need help setting up ftp user accounts and directory structures aikym1 Linux - Newbie 4 07-19-2004 03:17 PM
Help! How do you delete a directory tree? johnmcollier Linux - Security 0 10-24-2003 02:29 AM
Directory Tree Question GreatMilenko Linux - Security 3 06-02-2002 01:48 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 07:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration