Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to pipe the diff output into patch? The -i parameter is for specifying a diff file, but I just want to do it more dynamically, since I will be updating regularly against a directory that changes frequently.

For instacne, something along the lines of

patch -b | diff -Nub . /current-files


The man file says

-i patchfile  or  --input=patchfile
Read the patch from patchfile.  If patchfile is -, read from standard input, the default.

But when I try it, I just see the output of the diff on the screen, with no changes applied:

testb $> ls

testb $> patch -i - | diff -Nub . ../testa
diff -Nub ./file.txt ../testa/file.txt
--- ./file.txt  2011-07-12 09:40:08.195467000 -0400
+++ ../testa/file.txt   2011-07-12 09:39:11.181666500 -0400
@@ -1,9 +1,7 @@

diff -Nub ./file2.txt ../testa/file2.txt
--- ./file2.txt 1969-12-31 19:00:00.000000000 -0500
+++ ../testa/file2.txt  2011-07-12 09:39:44.196235000 -0400
@@ -0,0 +1,6 @@

testb $> ls
share|improve this question
up vote 9 down vote accepted

Don't you want the other way around?

diff -Nub . /current-files | patch -b
share|improve this answer
Yes, I think I do :) – user394 Jul 12 '11 at 13:55

Your Answer


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.