I have a directory with .patch files, generated using diff.

I would like to apply all those patches using patch -p1 to another directory.

But patch takes only one file, unless I cat.

What would the command be to apply multiple files using xargs or a similar tool.

link|improve this question
I like both solutions below, thanks guys! – styts Jan 13 '10 at 16:33
1  
Then why not upvote them? – womble Jan 13 '10 at 20:59
A reputation of 15 is required to upvote. – styts Jan 16 '10 at 9:55
ah, finally enough points.. both solutions upvoted! – styts Jul 1 '10 at 12:28
feedback

2 Answers

up vote 3 down vote accepted

If cat works, why not use it?

To use find and xargs:

find dirname -name namespec -print 0 | xargs -0 patch patchargs
link|improve this answer
feedback

Assuming you're using bash/sh/zsh etc...

cd /path/to/source
for i in /path/to/patches/*.patch; do patch -p1 < $i; done
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.