bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: diff directories: How do I identify changed files in a script-friend


From: Bob Proulx
Subject: Re: diff directories: How do I identify changed files in a script-friendly way?
Date: Sat, 7 Feb 2009 12:15:00 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Alan,

Alan Mackenzie wrote:
> [cc:'s to me would be appreciated.]
> The nearest facility I can find is diff -q ~/orig ~/new, which gives
> "user friendly" output thusly:
> 
>     Files ~/orig/cc-defs.el and ~/new/cc-defs.el differ
>     Files ~/orig/README and ~/new/README differ
> 
> .  Have I missed a way of getting scriptable output, or do I need to
> filter out the crud by hand?  Or can a later version give script
> friendly output?

I always hate negative information replies that say there isn't a way
because perhaps there is a better way?  But as far as I know that is
the best output available from the diff program for your purpose.  You
would need to filter it.  This comes to mind.  Note that it isn't safe
with regards to whitespace in filenames but if you don't have that
then this works.

  diff -q ~/orig ~/new | awk '{print$2}' | xargs -L1 basename

However there are other tools that may provide you with a more direct
result.  You might want to peek at the old dircmp script that used to
ship with Unix systems.  Unfortunately I don't have a running copy at
the moment and can't remember what the output format was like.  But it
was a script and hackable.

  http://www.opengroup.org/onlinepubs/007908775/xcu/dircmp.html

But in the end I would probably use 'rsync' to generate the list you
want to know about.  It would also need some tinkering but something
like the following comes to mind.

  rsync -n --out-format="%n" -aO ~/orig ~/new

Hope that helps,
Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]