On 05-Nov-97 Remco Blaakmeer wrote:
> On Tue, 4 Nov 1997, Sam Ockman wrote:
>> I need to take the diff of two directories recursively, but am not just
>> interested in what files are different...I'm also interested in if the
>> dates
>> of the files are different, the uids, the gids, and the permissions.
>> Anyone
>> know of a program to tell me all of this?
>
> One solution that crossed my mind:
> You could tar one of the dirs and let tar compare the contents of the
> .tar
> file with the other dir.
>
> I know this is not a very good solution, but I couldn't think of a better
> one.
>
> Remco
You could do this rather thoroughly with "paste" and "awk", assuming that
the results of "ls -lR" gave identical tree-structures (including numbers
of files in each directory) from the two trees.
ls -lR tree1 > temp1
ls -lR tree2 > temp2
paste temp1 temp2 > temp
The each line of temp either consists of two cognate directory names, side
by side (two fields), or two totals (four fields) else a line consisting of
two file listings like
-rw-rw-r-- 1 root root 8390 Sep 14 22:06 temp2.ps\t\
-rw-rw-r-- 1 root root 8390 Sep 14 22:06 temp2.ps
side by side (the "\t\" means that they're on the same line, separated by a
tab), with 9 fields in each
Then the space/tab-separated bits are fields as awk understands the term, so
it is straightforward to write an awk script that will report on every
difference between the first permissions and the second permissions,
and/or between the owners, groups, sizes, months, days, years/times and
names that you're interested in.
E.g.
awk < temp '{ if(NF > 4) {
if($1 != $10) {print $1 $9 " differs from " $10 $18 } }
}'
would output the two permissions if different with the filenames.
You could make it much more elaborate, including outputting the directory
paths (test for "NF==2", and store $1 and $2 as variables) or the directory
totals (test for "NF==4").
However, I suspect there may be a more elegant solution (perl, anyone ... ?)
Of course, if numbers of directories at each level, or numbers of files in
each directory, differed somewhere then the above would get out of phase
and fail. You could pre-empt this by some pre-processing, but then it
starts to get hairy.
Another much less controllable but much simpler option would just be
diff temp1 temp2
Ted.
--------------------------------------------------------------------
E-Mail: Ted Harding <Ted.Harding@nessie.mcc.ac.uk>
Date: 05-Nov-97 Time: 01:44:01
--------------------------------------------------------------------
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .