Utiliser diff et patch sous Linux
Code TEXT :
9 [22:16:10] adrien@superlinux: ~/tmp/patch/3 $ echo abc >> fic 10 [22:16:18] adrien@superlinux: ~/tmp/patch/3 $ echo abc >> fic2 11 [22:16:20] adrien@superlinux: ~/tmp/patch/3 $ echo def >> fic 12 [22:16:28] adrien@superlinux: ~/tmp/patch/3 $ echo def >> fic2 13 [22:16:29] adrien@superlinux: ~/tmp/patch/3 $ echo ghi >> fic 14 [22:16:34] adrien@superlinux: ~/tmp/patch/3 $ ls fic fic2 15 [22:16:35] adrien@superlinux: ~/tmp/patch/3 $ cat fic abc def ghi 16 [22:16:38] adrien@superlinux: ~/tmp/patch/3 $ cat fic2 abc def 17 [22:16:42] adrien@superlinux: ~/tmp/patch/3 $ diff -u fic fic2 --- fic 2013-04-21 22:16:34.744712277 +0200 +++ fic2 2013-04-21 22:16:29.408587703 +0200 @@ -1,3 +1,2 @@ abc def -ghi 18 [22:17:08] adrien@superlinux: ~/tmp/patch/3 $ diff -u fic2 fic --- fic2 2013-04-21 22:16:29.408587703 +0200 +++ fic 2013-04-21 22:16:34.744712277 +0200 @@ -1,2 +1,3 @@ abc def +ghi 19 [22:17:19] adrien@superlinux: ~/tmp/patch/3 $ diff -u fic2 fic > patch.patch 20 [22:17:24] adrien@superlinux: ~/tmp/patch/3 $ patch -p0 fic2 < patch.patch patching file fic2 21 [22:17:40] adrien@superlinux: ~/tmp/patch/3 $ cat fic2 abc def ghi 22 [22:17:43] adrien@superlinux: ~/tmp/patch/3 $ 28 [13:59:09] adrien@marrowgar: ~ $ cd tmp/patch/ 29 [13:59:14] adrien@marrowgar: ~/tmp/patch $ cat 1/fic abc def ghi 30 [13:59:18] adrien@marrowgar: ~/tmp/patch $ cat 1/fic.orig cat: 1/fic.orig: Aucun fichier ou dossier de ce type 31 [13:59:23] adrien@marrowgar: ~/tmp/patch $ cat 1/fic.ori abc def 32 [13:59:25] adrien@marrowgar: ~/tmp/patch $ cat 2/fic abc def 33 [13:59:29] adrien@marrowgar: ~/tmp/patch $ diff -u 1/fic fic fic.ori 33 [13:59:29] adrien@marrowgar: ~/tmp/patch $ diff -u 1/fic.ori 1/fic --- 1/fic.ori 2013-03-17 13:57:20.296386279 +0100 +++ 1/fic 2013-03-17 13:57:27.792385772 +0100 @@ -1,2 +1,3 @@ abc def +ghi 34 [13:59:46] adrien@marrowgar: ~/tmp/patch $ diff -u 1/fic.ori 1/fic > patch-fic.patch 25 [14:13:50] adrien@marrowgar: ~/tmp/patch $ patch 2/fic < patch-fic.patch patching file 2/fic 35 [13:59:59] adrien@marrowgar: ~/tmp/patch $ cat 2/fic abc def 36 [14:00:08] adrien@marrowgar: ~/tmp/patch $ cp -R 1 1-ori 37 [14:00:45] adrien@marrowgar: ~/tmp/patch $ ls 1/ 1-ori/ 2/ patch-fic.patch 38 [14:00:46] adrien@marrowgar: ~/tmp/patch $ rm -rf 1 39 [14:00:57] adrien@marrowgar: ~/tmp/patch $ ls 1-ori/ 2/ patch-fic.patch 40 [14:00:59] adrien@marrowgar: ~/tmp/patch $ patch -p0 < patch-fic.patch can't find file to patch at input line 3 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |--- 1/fic.ori 2013-03-17 13:57:20.296386279 +0100 |+++ 1/fic 2013-03-17 13:57:27.792385772 +0100 -------------------------- File to patch: ^C 41 [14:01:16] adrien@marrowgar: ~/tmp/patch $ patch -p1 2/ < patch-fic.patch patch: **** File 2/ is not a regular file -- can't patch 42 [14:01:24] adrien@marrowgar: ~/tmp/patch $ patch -p1 2 < patch-fic.patch patch: **** File 2 is not a regular file -- can't patch 43 [14:01:31] adrien@marrowgar: ~/tmp/patch $ patch -p1 < patch-fic.patch can't find file to patch at input line 3 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |--- 1/fic.ori 2013-03-17 13:57:20.296386279 +0100 |+++ 1/fic 2013-03-17 13:57:27.792385772 +0100 -------------------------- File to patch: ^C 44 [14:01:40] adrien@marrowgar: ~/tmp/patch $ 2 [14:01:44] adrien@marrowgar: ~/tmp/patch $ 2 [14:02:23] adrien@marrowgar: ~/tmp/patch $ patch -p0 2/fic < patch-fic.patch patching file 2/fic 3 [14:02:32] adrien@marrowgar: ~/tmp/patch $ cat 2/fic abc def ghi 4 [14:02:39] adrien@marrowgar: ~/tmp/patch $ nano 2/fic 5 [14:03:02] adrien@marrowgar: ~/tmp/patch $ cat 2/fic abc def 6 [14:03:04] adrien@marrowgar: ~/tmp/patch $ mv 2 1 7 [14:03:14] adrien@marrowgar: ~/tmp/patch $ cat 1/fic abc def 8 [14:03:18] adrien@marrowgar: ~/tmp/patch $ cat patch-fic.patch --- 1/fic.ori 2013-03-17 13:57:20.296386279 +0100 +++ 1/fic 2013-03-17 13:57:27.792385772 +0100 @@ -1,2 +1,3 @@ abc def +ghi 9 [14:03:20] adrien@marrowgar: ~/tmp/patch $ patch -p0 < patch-fic.patch patching file 1/fic 10 [14:03:26] adrien@marrowgar: ~/tmp/patch $ 10 [14:07:27] adrien@marrowgar: ~/tmp/patch $ cat 1/fic cat: 1/fic: Aucun fichier ou dossier de ce type 11 [14:07:34] adrien@marrowgar: ~/tmp/patch $ cat 2/fic abc def 12 [14:07:38] adrien@marrowgar: ~/tmp/patch $ cat patch-fic.patch --- 1/fic.ori 2013-03-17 13:57:20.296386279 +0100 +++ 1/fic 2013-03-17 13:57:27.792385772 +0100 @@ -1,2 +1,3 @@ abc def +ghi 13 [14:07:41] adrien@marrowgar: ~/tmp/patch $ patch -p0 < patch-fic.patch can't find file to patch at input line 3 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |--- 1/fic.ori 2013-03-17 13:57:20.296386279 +0100 |+++ 1/fic 2013-03-17 13:57:27.792385772 +0100 -------------------------- File to patch: ^C 14 [14:07:50] adrien@marrowgar: ~/tmp/patch $ patch -p1 < patch-fic.patch can't find file to patch at input line 3 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |--- 1/fic.ori 2013-03-17 13:57:20.296386279 +0100 |+++ 1/fic 2013-03-17 13:57:27.792385772 +0100 -------------------------- File to patch: ^C 15 [14:07:55] adrien@marrowgar: ~/tmp/patch $ cp patch-fic.patch 2/patch-fic.patch 16 [14:08:08] adrien@marrowgar: ~/tmp/patch $ cd 2/ 17 [14:08:10] adrien@marrowgar: ~/tmp/patch/2 $ patcp -p0 < patch-fic.patch bash: patcp : commande introuvable 18 [14:08:17] adrien@marrowgar: ~/tmp/patch/2 $ patch -p0 < patch-fic.patch can't find file to patch at input line 3 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |--- 1/fic.ori 2013-03-17 13:57:20.296386279 +0100 |+++ 1/fic 2013-03-17 13:57:27.792385772 +0100 -------------------------- File to patch: ^C 19 [14:08:23] adrien@marrowgar: ~/tmp/patch/2 $ patch -p1 < patch-fic.patch patching file fic 20 [14:08:26] adrien@marrowgar: ~/tmp/patch/2 $