LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


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

Rep: Reputation: 0
hel: 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
 
  


Reply



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
Help: regarding comparing two directory tree structures raj_thota Solaris / OpenSolaris 1 11-02-2005 07:16 AM
permissions for directory tree adamwenner Linux - Security 3 10-23-2004 07:39 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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:10 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