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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-07-2012, 06:35 PM
|
#1
|
LQ Newbie
Registered: Aug 2012
Posts: 4
Rep:
|
Shell Script to compare folders,Sub-Folders and Sub-Sub-Folders
Dear All,
I am trying to built a shell script which will compare all the folders like directories,sub-dir and sub-sub-Dir between two servers.
Can it be possible ?
If yes, Could you please give some idea which will help me a lot .
Thanks.
|
|
|
08-07-2012, 06:56 PM
|
#2
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,330
|
Quote:
Originally Posted by unix_72427
Dear All,
I am trying to built a shell script which will compare all the folders like directories,sub-dir and sub-sub-Dir between two servers.
Can it be possible ?
If yes, Could you please give some idea which will help me a lot .
Thanks.
|
very possible. I suggest you look up some of the bash scripting tutorials you can find on google.
what are you trying to accomplish? It could be that you could use rsync for another utility to do what you want to do.
|
|
|
08-07-2012, 07:29 PM
|
#3
|
LQ Newbie
Registered: Aug 2012
Posts: 4
Original Poster
Rep:
|
Quote:
Originally Posted by TB0ne
very possible. I suggest you look up some of the bash scripting tutorials you can find on google.
what are you trying to accomplish? It could be that you could use rsync for another utility to do what you want to do.
|
Hi,
Thanks for your quick response,
i want to compare files from two servers folders ,sub-folders,sub-sub-folders and so on ...
i searched through out the forum but i am not getting any satisfactory answer .
Need your help to achieve the above .
Thanks.
|
|
|
08-08-2012, 03:00 AM
|
#4
|
Member
Registered: Jan 2011
Location: Shanghai,China
Distribution: fedora
Posts: 73
Rep:
|
diff command will show two directory's difference.
[root@~]diff dir1 dir2
|
|
|
08-08-2012, 10:01 AM
|
#5
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,330
|
Quote:
Originally Posted by unix_72427
Hi,
Thanks for your quick response,
i want to compare files from two servers folders ,sub-folders,sub-sub-folders and so on ... i searched through out the forum but i am not getting any satisfactory answer .
|
Ok, so again, post what you've written, and what you're trying to accomplish, and we can try to help. But, we are NOT going to write your scripts for you. There are many bash scripting guides you can find with a VERY easy Google search, like this:
http://tldp.org/LDP/abs/html/
The diff command can do some parts of what you want, but again, you're not telling us what your goal is. If this is homework, post where you're stuck. If it's for a production environment, there are other tools you can use to do this.
|
|
|
08-08-2012, 11:32 AM
|
#6
|
LQ Newbie
Registered: Aug 2012
Posts: 4
Original Poster
Rep:
|
Quote:
Originally Posted by TB0ne
Ok, so again, post what you've written, and what you're trying to accomplish, and we can try to help. But, we are NOT going to write your scripts for you. There are many bash scripting guides you can find with a VERY easy Google search, like this:
http://tldp.org/LDP/abs/html/
The diff command can do some parts of what you want, but again, you're not telling us what your goal is. If this is homework, post where you're stuck. If it's for a production environment, there are other tools you can use to do this.
|
Hi,
Am trying to achieve like
for Example.
Code:
Serv 1
========
/admin
A
X
Y
B
Z
W
C
/properties
1
4
5
7
12
d
e
/super
22
========
Serv 2
========
/admin
A
X
Y
O
B
Z
W
C
/properties
1
4
5
12
d
e
=============
O/P
-------------
Serv1 Serv2
----------------------------------------------
/admin/A/ 1.)/
------- ------------
missing folder O missing /super folder
2.)/properties/1
----------
missing folder 7
I gathered all the directories from both the servers in text file and am trying to put them in some loop like reading each line .
Code:
line=$1
while read LINE
do
grep the line in both the file and spool into a file.
done < $line
Here am not sure will work or not . will glad if you give some input .
Last edited by unix_72427; 08-08-2012 at 11:56 AM.
|
|
|
08-08-2012, 11:53 AM
|
#7
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,330
|
Quote:
Originally Posted by unix_72427
Hi,
Am trying to achieve like for Example.
|
Right...we understand what you're trying to do, and have since your first post. What we are asking for is - The code that YOU have written to do this
- You to tell us where you're stuck or what problem(s) you're having
- What your GOAL is..for example, is this to verify a backup, sync two servers over a WAN...what???
What effort have you put into solving this problem? Is this homework?? Just asking the same question over and over, without answering anyone elses questions won't get you much help....
|
|
|
08-08-2012, 12:01 PM
|
#8
|
LQ Newbie
Registered: Aug 2012
Posts: 4
Original Poster
Rep:
|
Quote:
Originally Posted by TB0ne
Right...we understand what you're trying to do, and have since your first post. What we are asking for is - The code that YOU have written to do this
- You to tell us where you're stuck or what problem(s) you're having
- What your GOAL is..for example, is this to verify a backup, sync two servers over a WAN...what???
What effort have you put into solving this problem? Is this homework?? Just asking the same question over and over, without answering anyone elses questions won't get you much help....
|
This is not a homework. am trying in production environment to compare two servers and manually fill the gap.
|
|
|
08-08-2012, 03:51 PM
|
#9
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,330
|
Quote:
Originally Posted by unix_72427
This is not a homework. am trying in production environment to compare two servers and manually fill the gap.
|
Ok...and how about the other parts of what we've been asking you??? - The code that YOU have written to do this
- You to tell us where you're stuck or what problem(s) you're having
- What effort have you put into solving this problem?
If you're trying to keep two production servers in sync, use rsync, which was suggested to you in the very first reply. Have you looked up the command, and how it's used? This is what it was written for, and (since you say this is not homework), you should be able to use any utility you'd like.
|
|
|
All times are GMT -5. The time now is 02:02 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|