|
Home > Archive > Unix questions > January 2006 > Variation of "diff -qr" to compare file sizes/dates between file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Variation of "diff -qr" to compare file sizes/dates between file
|
|
| Dubious Dude 2006-01-29, 9:31 pm |
| I created a CD volume that backs up some of my laptop. After some
time has past, I'd like to check what files need freshening up i.e.
what files on the laptop either have no counterpart on the CD, or
which have changed from its counterpart on the CD. I am running
Cygwin on Windows 2000, so I have access to unix-like (gnu) commands.
I've typically run "diff -qr" to find differences between the file
hierarchies on the CD and the hard drive. However, this does a
bit-by-bit compare, which is way more intensive than what I'm looking
for, and takes way too long. I want to check only the size and date
of nondirectory files. Basically emulate a human being looking at a
directory listing. Sometimes, the permissions on the CD differ from
that on HD, but I'm not worried about that.
I was using "find * -ls" or "find * | xargs ls -ld" for each file
tree, then use vimdiff to look for the differences. Before looking,
however, I use "sed" to remove the details that don't relate to file
size or date. This works poorly because of discrepancies in the
alphabetic sorting. On the hard drive, A-Z precedes a-z, while the
sorting of CD files seem to be case insensitive. It also seems to
cause the CD drive to thrash quite a bit, though it might simply be
due to the short amount of time spent on each file. Finally, the
directories on the CD are dated according to the time that it burned,
though that can be solved by having "find" return only
nondirectories. It doesn't solve the other problems, though.
I tried "ls -lR", but the output is not diff-friendly. Each file
does not have the full path, and there are too many places for
diff to get confused e.g. lots of blank lines, directory totals,
and the filenames are preceded by the numeric sizes. I'm sure
that with enough filtering, some of the problems can be removed,
but it doesn't look like a pretty way to do it.
Is there a more straightforward way to make this comparison? I'm
resorting to "diff -qr" for the time being.
| |
| Conrad J. Sabatier 2006-01-29, 9:31 pm |
| In article <dre18p$10e$1@domitilla.aioe.org>,
Dubious Dude <Shifty@eyes.com> wrote:
>
>
>I created a CD volume that backs up some of my laptop. After some
>time has past, I'd like to check what files need freshening up i.e.
>what files on the laptop either have no counterpart on the CD, or
>which have changed from its counterpart on the CD. I am running
>Cygwin on Windows 2000, so I have access to unix-like (gnu) commands.
>I've typically run "diff -qr" to find differences between the file
>hierarchies on the CD and the hard drive. However, this does a
>bit-by-bit compare, which is way more intensive than what I'm looking
>for, and takes way too long. I want to check only the size and date
>of nondirectory files. Basically emulate a human being looking at a
>directory listing. Sometimes, the permissions on the CD differ from
>that on HD, but I'm not worried about that.
Does Cygwin have a "stat" command? This can be used to return only the
information you want about a file.
For example:
serene:conrads:/bin$ stat -f "%Sa %8z %N" *
Jan 26 06:43:14 2006 11304 [
Jan 27 23:30:00 2006 11208 cat
Jan 27 12:32:08 2006 7304 chflags
Jan 25 10:19:53 2006 17128 chio
(output truncated)
This, in combination with find/xargs, should do the trick nicely, I would
think.
--
Conrad J. Sabatier <conrads@cox.net> -- "In Unix veritas"
| |
| Dubious Dude 2006-01-29, 9:31 pm |
| Conrad J. Sabatier wrote:
>Dubious Dude <Shifty@eyes.com> wrote:
>
> Does Cygwin have a "stat" command? This can be used to return only the
> information you want about a file.
>
> For example:
>
> serene:conrads:/bin$ stat -f "%Sa %8z %N" *
> Jan 26 06:43:14 2006 11304 [
> Jan 27 23:30:00 2006 11208 cat
> Jan 27 12:32:08 2006 7304 chflags
> Jan 25 10:19:53 2006 17128 chio
> (output truncated)
>
> This, in combination with find/xargs, should do the trick nicely, I would
> think.
Unfortunately, my installation of cygwin doesn't have stat, and the
bandwidth of my current internet access makes it impractical to update
cygwin. However, I did look at online man pages to see that it does
seem to do the job. I also found that it is part of the current
cygwin coreutils package (see tangent note 1), so I can get it in the future.
Thanks for pointing that out.
Tangent Note 1:
The indirect path of finding whether cygwin has stat command
------------------------------------------------------------
The word "stat" is very common, making web search haphazard. One has
to beware of the existence of a corresponding "stat" C library
function and associated man page. There were many references to
e2fsimage, apparently a wrapper for stat, but the purpose seems to be
different i.e. creating a file system image. At the cygwin site, the
package search doesn't allow specification of whole word matches, so
the number of unrelated hits were quite high. Indication of whether
a package contained the "stat" command was found at
http://svn.haxx.se/dev/archive-2006-01/0536.shtml, and confirmed at
http://cygwin.com/packages/coreutils/coreutils-5.93-3.
|
|
|
|
|