有没有办法将差异输出通过管道传输到patch
?-i 参数用于指定 diff 文件,但我只想更动态地执行此操作,因为我将针对频繁更改的目录定期更新。
对于 instacne,类似的东西
patch -b | diff -Nub . /current-files
Run Code Online (Sandbox Code Playgroud)
?
人文件说
-i patchfile or --input=patchfile
Read the patch from patchfile. If patchfile is -, read from standard input, the default.
Run Code Online (Sandbox Code Playgroud)
但是当我尝试时,我只是在屏幕上看到 diff 的输出,没有应用任何更改:
testb $> ls
file.txt
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 @@
ijaosdfji
jaiosdfjio
jklasdkml
-asdkml
-s;lnk
-lsadjkl
-asdfas
-asdf
+klasdkml
+nas;lnk
+jklsadjkl
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 @@
+aljksdf
+jklasdflkjlknm
+nksalk;
+klaskl;
+ioasjdoiaj
+lkmasd'lkm
testb $> ls
file.txt
Run Code Online (Sandbox Code Playgroud)
l0b*_*0b0 12
你不想反过来吗?
diff -Nub . /current-files | patch -b
Run Code Online (Sandbox Code Playgroud)