Cygwin diff won't exclude files if a directory is included in the pattern
I need to do a recu开发者_JAVA百科rsive diff using cygwin that needs do exclude all .xml files from certain directories, but not from other directories. According to the --help option I should be able to do this with with the --exclude=PAT option where PAT is a pattern describing the files I want to exclude from the diff.
If I do this:
diff -rw --exclude="classes/Services.xml"
the diff does not ignore the Services.xml file in the classes directory. If I do this
diff -rw --exclude="Services.xml"
the diff does ignore the Services.xml file in all directories.
I need to do something like this:
diff -rw --exclude="*/generated/resources/client/*.xml"
to ignore all .xml files in the directory */generated/resources/client/.
Whenever I add path information to the --exclude pattern cygwin does not ignore the file(s) I've specified in the pattern.
Is there some way to make cygwin diff recognize a pattern that identifies certain files in certain directories? It seems to not be able to handle any directory information at all.
I ended up having to write a Java utility that walks the directory tree, excluding certain directories, and calls diff on each level.
Use find
with an approprite expression. Assuming your trees are in tree1/
and tree2/
, then
$ find tree1 -type f ! -path '*classes/Services.xml' |
while read f; do diff -rw "$f" "tree2${f#tree1}"; done
Hmmm, as it stands this misses files in tree2/
that do not exist in tree1/
.
精彩评论