[Ilugc] .a-tip-a-day (patch - apply diffs and act as inverse of diff)

  • From: steve@xxxxxxxxxxxx (steve)
  • Date: Wed Sep 30 11:58:52 2009

On 09/30/2009 11:27 AM, Girish Venkatachalam wrote:

[...snip...]
...so, you can also send multiple patchfiles to patch ...


Of course, that is a good thing. The utility is powerful but I don't like
it. It should have been way more simpler and friendlier and still powerful.

I'm sorry, I don't understand. The way i see it, there is nothing complicated or
unfriendly about patch. It is small, /simple/ and flexible.

AFAIK, diff and patch are supposed to complement each other. In other words, the
output of diff can be used as input to patch directly ...even in a chain:

-------------------------------------------------------------
[steve@laptop junkyard]$ cat sample.txt
Osborn's Law:
     Variables won't; constants aren't.

[steve@laptop junkyard]$ cat sample.txt | tr '[a-z]' '[A-Z]' > sample-upper.txt

[steve@laptop junkyard]$ diff -u sample.txt sample-upper.txt
--- sample.txt  2009-09-30 11:50:54.000000000 +0530
+++ sample-upper.txt    2009-09-30 11:53:21.000000000 +0530
@@ -1,2 +1,2 @@
-Osborn's Law:
-    Variables won't; constants aren't.
+OSBORN'S LAW:
+    VARIABLES WON'T; CONSTANTS AREN'T.

[steve@laptop junkyard]$ diff -u sample.txt sample-upper.txt | patch -p0
patching file sample.txt

[steve@laptop junkyard]$ cat sample.txt
OSBORN'S LAW:
     VARIABLES WON'T; CONSTANTS AREN'T.
[steve@laptop junkyard]$
-------------------------------------------------------------

Just curious, what would your ideal invocation of patch be ?

cheers,
- steve
-- 
random non tech spiel: http://lonetwin.blogspot.com/
tech randomness: http://lonehacks.blogspot.com/
what i'm stumbling into: http://lonetwin.stumbleupon.com/

Other related posts: