Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...What you have done for people like me is immeasurably helpful."

Geography

Where in the world do Tek-Tips members come from?

Script to Compare two directories

grapes12 (TechnicalUser)
4 Apr 12 6:23
I have the following script which is to compare two directories using the sdiff command

CODE

 #!/bin/ksh

LOCALFOLDER=/u1/mac2
REMOTEFOLDER=$(rsh sun5 'ls -lA /u1/mac2' > remotessh.txt)
COMMAND=$(ls -lA $LOCALFOLDER > localssh.txt)
REM=$(cat remotessh.txt)
LOCAL=$(cat localssh.txt)

echo $LOCAL
echo $REM

if [ $REM -eq $LOCAL ]
 then
      echo Directories are the same
 else
      echo Directories are differnt
 fi

#sdiff localssh.txt remotessh.txt | grep '\|'

The output files were created from local and remote servers, I need to put the differences into another file and email the differences how will I do that?

I would also like to cut from the files created the permissions etc, how can i do that?
herewith output file

CODE

drwxrwxr-x   3 mac2     querix         3 Nov 30 00:00 .sunstudio
drwx------   3 mac2     querix         3 Nov 30 00:00 .sunw
drwxr-xr-x   3 mac2     querix         3 Nov 30 00:00 .vim
-rw-rw-r--   1 mac2     querix      6197 Nov 30 00:00 .viminfo
-rw-rw-r--   1 mac2     querix       102 Nov 30 00:00 .vimrc
-rw-------   1 mac2     querix       200 Nov 30 00:00 .Xauthority
-rwxrwxr-x   1 mac2     querix     46352 Nov 30 00:00 a_calc00.4ge
-rw-rw-r--   1 mac2     querix     11902 Nov 30 00:00 a_calc00.4gl
-rw-rw-r--   1 mac2     querix        60 Nov 30 00:00 a_calc00.def
-rw-rw-r--   1 mac2     querix      1527 Nov 30 00:00 a_calc01.per
-rw-rw-r--   1 mac2     querix      1464 Nov 30 00:00 a_calc01.pic
-rwxrwxr-x   1 mac2     querix     66208 Nov 30 00:00 a_ecb000.4ge
-rw-rw-r--   1 mac2     querix     24895 Nov 30 00:00 a_ecb000.4gl
-rw-rw-r--   1 mac2     querix       112 Nov 30 00:00 a_ecb000.def
-rw-rw-r--   1 mac2     querix       444 Nov 30 00:00 a_ecb000.per
-rw-rw-r--   1 mac2     querix       322 Nov 30 00:00 a_ecb000.pic
-rw-rw-r--   1 mac2     querix      1929 Nov 30 00:00 a_ecb001.per
-rw-rw-r--   1 mac2     querix      2357 Nov 30 00:00 a_ecb001.pic
 
FlorianAwk (Programmer)
4 Apr 12 17:02
To keep the first column of "myfile.txt", type:

CODE

awk '{print $1}' myfile.txt
tarn (TechnicalUser)
4 Apr 12 18:08
Would you not be better off checking checksum/MD5 Sum's of the files within directories on each of the specific nodes building a sorted listing then fetch the lists from each node and diff them against the master node, producing a report for each?

Or is that a bit too low-level for your needs?

Or you could utilize something like Tripwire that does that and more for you ;)


Laurie.    
grapes12 (TechnicalUser)
5 Apr 12 3:08
Thanks,

I got the Awk working.BUT i have sub-directories within the directory that i would also like to check.
I changed my script to do a "ls -lAR" to include files from all subdirectories.

MY txt file displaying all differences is much bigger, but not showing me in which directory the differences are
How can i change my script to list the directories and the files within that sub-directories.
Annihilannic (MIS)
6 Apr 12 5:26
Instead of using ls -lAR try using find /u1/mac2 | xargs ls -ld, that way it should include the full path with every filename.

Annihilannic
tgmlify - code syntax highlighting for your tek-tips posts

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close