Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff & patch
% pwd
/tmp/ex
% mkdir old
% echo "0xFF 255 11111111" > old/stuff
% echo "192.168.0.0/16" > old/net
% cp -R old new
% echo "192.168.2.0/24" > old/net
% echo "0xF0 240 11110000" > old/stuff
% diff -r -u old/ new/ > patchfile
% cat patchfile
diff -r -u old/net new/net
--- old/net 2015-07-10 17:55:38.000000000 +0200
+++ new/net 2015-07-10 17:55:21.000000000 +0200
@@ -1 +1 @@
-192.168.2.0/24
+192.168.0.0/16
diff -r -u old/stuff new/stuff
--- old/stuff 2015-07-10 17:57:01.000000000 +0200
+++ new/stuff 2015-07-10 17:55:21.000000000 +0200
@@ -1 +1 @@
-0xF0 240 11110000
+0xFF 255 11111111
%
%
% cd old/
% patch -p1 --dry-run < ../patchfile
patching file net
patching file stuff
% patch -p1 < ../patchfile
patching file net
patching file stuff
% cat stuff net
0xFF 255 11111111
192.168.0.0/16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment