Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Mar 2010 18:41:05 +1100 (EST)
From:      Ian Smith <smithi@nimnet.asn.au>
To:        "Aryeh M. Friedman" <aryeh.friedman@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: how to compare permissions between two dirs
Message-ID:  <20100323181056.I85436@sola.nimnet.asn.au>
In-Reply-To: <20100322120021.C2A26106571B@hub.freebsd.org>
References:  <20100322120021.C2A26106571B@hub.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In freebsd-questions Digest, Vol 303, Issue 2, Message: 11
On Mon, 22 Mar 2010 07:33:28 -0400 "Aryeh M. Friedman" <aryeh.friedman@gmail.com>

 > In switching to a new make file for a personal project I have run into 
 > the problem of under the old makefile everything works (web site) and 
 > under the new one it does not... when manually looking at the two dirs 
 > they appear identical in layout, sizes and perms (dir and file level) 
 > but I want to make sure... is there any way to compare two diff dirs and 
 > see if they only differ in date stamps? (note since there are several 
 > developers working on this project I need to compare even if the owners 
 > are diff)

% diff dir1 dir2
should do what you need, to compare file existence and contents.

% ls -lrt bittorrent bittorrent2
bittorrent2:
total 82
-rw-r-----  1 smithi  smithi  81110 Nov 22  2004 bittorrentecon.pdf
-rw-r-----  1 smithi  smithi      0 Jun  9  2006 not_in_1
-rw-r-----  1 smithi  smithi     49 Jun  9  2006 differingfile

bittorrent:
total 82
-rw-r-----  1 smithi  smithi  81110 Nov 22  2004 bittorrentecon.pdf
-rw-r-----  1 smithi  smithi      0 Jun  9  2006 not_in_2
-rw-r-----  1 smithi  smithi     28 Jun  9  2006 differingfile

% diff bittorrent bittorrent2
diff bittorrent/differingfile bittorrent2/differingfile
1,2c1,3
< this one in bittorrent dir
<
---
> this one in bittorrent2 dir
> with an extra line
>
Only in bittorrent2: not_in_1
Only in bittorrent: not_in_2

Then to just compare (eg) permissions and names, something like:

ls -la dir1 | awk '{print $1,$9}' >/tmp/lsd1
ls -la dir2 | awk '{print $1,$9}' >/tmp/lsd2
diff /tmp/lsd1 /tmp/lsd2

cheers, Ian



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100323181056.I85436>