Operating System - HP-UX
1830939 Members
1655 Online
110017 Solutions
New Discussion

Re: Compare to directory structures

 
hpuxrox
Respected Contributor

Compare to directory structures

Any one know how to compare a directory structure on one machine to another machine.

Im have a permission problem on one of the machines and the directories and files are quit extensive.

Thanks
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: Compare to directory structures


machine 1
dir *. > mach1

machine 2

dir *. > mach2


ftp, scp whatever

diff the two files

dir is an alias for us that does an ll -d

If its a paticular file, then use ll -R instead of dir

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ken Penland_1
Trusted Contributor

Re: Compare to directory structures

If you just want to know about the perms on the directories, you could do a:

find /dir1 -type d -exec ls -ald {} \; > /tmp/dir1

find /dir2 -type d -exec ls -ald {} \; > /tmp/dir2

then do a:

diff /tmp/dir1 /tmp/dir2

'
Abdul Rahiman
Esteemed Contributor

Re: Compare to directory structures

If you can narrow down your criteria in differences or some file attributes like name, ownership, permissions etc, you can generate two lists on both machines using a find command in combination mode,
eg: for files starting with abc* and permissions 644
# find . -name "abc*" -a -perm 0644 -exec ls -l {} \; > /tmp/a1

or for files owned by abc and permissions 600,
# find . -owner abc -a -perm 0644 -exec ls -l {} \; > /tmp/a1

Then comapre the outputs from both machines by sdiff.
to help the sdiff, just filter out the filelds with differences and probable do a sort before doing an sdiff.

HTH,
Abdul.
No unix, no fun
Rodney Hills
Honored Contributor

Re: Compare to directory structures

I would recommend you get the utility "els"-
http://hpux.cs.utah.edu/hppd/hpux/Users/els-1.48a/

This provides an extended ls utility which is easier to use with scripts.

Then do a list on the first directory-
cd /first/directory
/opt/els/bin/els -R +f':' +TI +G"F':1:'PUGsm" >/tmp/l1

Then do a list on the second-
cd /first/directory
/opt/els/bin/els -R +f':' +TI +G"F':2:'PUGsm" >/tmp/l2

Then run both through sort and uniq-
sort /tmp/l1 /tmp/l2 | sort -u >/tmp/notsame

The sort/uniq combination will filter out those files that are the same between the 2 directorites. What is left are files that exist in only one of the directories and files whose permission/uid/gid/size aren't the same.

HTH

-- Rod Hills
There be dragons...
Rodney Hills
Honored Contributor

Re: Compare to directory structures

oops-

Should have been-

sort /tmp/l1 /tmp/l2 | uniq -u >/tmp/notsame

-- Rod Hills
There be dragons...