LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Shell Script to compare folders,Sub-Folders and Sub-Sub-Folders (http://www.linuxquestions.org/questions/programming-9/shell-script-to-compare-folders-sub-folders-and-sub-sub-folders-4175420906/)

unix_72427 08-07-2012 06:35 PM

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. :confused:

TB0ne 08-07-2012 06:56 PM

Quote:

Originally Posted by unix_72427 (Post 4748455)
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. :confused:

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.

unix_72427 08-07-2012 07:29 PM

Quote:

Originally Posted by TB0ne (Post 4748468)
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.

jimtony 08-08-2012 03:00 AM

diff command will show two directory's difference.
[root@~]diff dir1 dir2

TB0ne 08-08-2012 10:01 AM

Quote:

Originally Posted by unix_72427 (Post 4748497)
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.

unix_72427 08-08-2012 11:32 AM

Quote:

Originally Posted by TB0ne (Post 4748962)
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 .

TB0ne 08-08-2012 11:53 AM

Quote:

Originally Posted by unix_72427 (Post 4749047)
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....

unix_72427 08-08-2012 12:01 PM

Quote:

Originally Posted by TB0ne (Post 4749063)
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.

TB0ne 08-08-2012 03:51 PM

Quote:

Originally Posted by unix_72427 (Post 4749068)
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 06:11 AM.