~ / howtos /

HOWTO diff & patch

Copyright © 2006—2007, Renaud Blanch.
mise à jour : 23 novembre 2007

Example

[plan9:~/temp] blanch% mkdir distrib
[plan9:~/temp] blanch% pico distrib/readme.txt
[plan9:~/temp] blanch% more distrib/readme.txt 
this is a readme file.
you should read me...
[plan9:~/temp] blanch% cp -R distrib work
[plan9:~/temp] blanch% more work/readme.txt 
this is a readme file.
you should read me...
[plan9:~/temp] blanch% pico work/readme.txt 
[plan9:~/temp] blanch% more work/readme.txt 
this is a readme file.
you should read me FIRST...
[plan9:~/temp] blanch% diff -ru distrib/ work/ > dummy.patch
[plan9:~/temp] blanch% more dummy.patch 
diff -ru distrib/readme.txt work/readme.txt
--- distrib/readme.txt  2006-03-17 17:45:04.000000000 +0100
+++ work/readme.txt     2006-03-17 17:45:45.000000000 +0100
@@ -1,2 +1,2 @@
 this is a readme file.
-you should read me...
+you should read me FIRST...
[plan9:~/temp] blanch% cp -R distrib/ new
[plan9:~/temp] blanch% cd new/
[plan9:~/temp/new] blanch% more readme.txt 
this is a readme file.
you should read me...
[plan9:~/temp/new] blanch% patch < ../dummy.patch 
patching file readme.txt
[plan9:~/temp/new] blanch% more readme.txt 
this is a readme file.
you should read me FIRST...