Take the 2-minute tour ×

I'm trying to generate patches for a bunch of files I changed. I'm using Meld which does a great job of diff’ing the files in a nice visual manor, then it allows me to save and generate a patch file based on those changes.

The problem I have is that it's slow to do this one at a time. Is there a similar tool that I can use for batch work? I want it to recursively check all the files in two directories and generate all the patch files based on its findings.

share|improve this question

2 Answers 2

up vote 2 down vote accepted




share|improve this answer
I think you're right, I was not aware of the -u option for diff, that does make the formatting the same. How would I update that line to avoid certain files? For example any *.o files that are in the directories. –  Mike Dec 5 '12 at 14:33
Use an --exclude={pattern} option. There are a number of options you may or may not want to use, I'd suggest reading through the man page to understand what's available. The diff program is actually quite powerful. –  John Dec 5 '12 at 14:37

That's what diff is for. patch takes diff output files as input. Just run diff in a BASH loop for each of your files. For example, if the original files are in dirA and the new ones in dirB (with the same filenames), do this (in ./dirA):

for n in $(ls * | grep -v ".o$"); do \
    diff -uN $n dirB/$n > $n.patch; patch $n < $n.patch; \
share|improve this answer
@Mike, see my updated answer for avoiding .o files. –  terdon Dec 5 '12 at 14:42

Your Answer


