Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|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

2 Answers 2

up vote 4 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
share|improve this answer

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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