Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3302203
  • 博文数量: 754
  • 博客积分: 10132
  • 博客等级: 上将
  • 技术积分: 7780
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-14 23:36
文章分类

全部博文(754)

文章存档

2012年(3)

2011年(39)

2010年(66)

2009年(167)

2008年(479)

我的朋友

分类: LINUX

2008-05-25 13:03:50

?? (更多技术知识请访问)
??
?? linux下的补丁文件由diff这个命令创建
??
??diff 选项:
??-u 以统一格式创建补丁文件,这种格式比缺省格式更紧凑些。
??-N 确保补丁文件将正确地处理已经创建或删除文件的情况。
??-r 递归比较命令行上所给出的两个目录的所有子目录中的所有文件。
??-a 比较二制文件
??
??使用方法一:为文件创建补丁
??[root@snowli dirtest]# more test_0.txt
??11111111111111111111
??11111111111111111111
??11111111111111111111
??[root@snowli dirtest]# more test_1.txt
??22222222222222222222
??11111111111111111111
??00000000000000000000
??11111111111111111111
??
??下面我们创建针对test0_.txt的补丁:
??[root@snowli dirtest]# diff -uN test_0.txt test_1.txt > test_1.patch
??补丁文件的内容如下:
??[root@snowli dirtest]# more test_1.patch
??--- test_0.txt 2005-01-13 11:52:56.785874968 +0800
??+++ test_1.txt 2005-01-13 11:54:33.243211224 +0800
??@@ -1,3 +1,4 @@
??+22222222222222222222
??11111111111111111111
??-11111111111111111111
??+00000000000000000000
??11111111111111111111
??
??使用方法一:为工程目录下所有文件创建补丁
??有两个目录pro0 和pro1
??两个目录及下面的文件内容如下:
??[root@snowli dirtest]# ls pro0
??a_0.txt test_0.txt
??[root@snowli dirtest]# more pro0/*
??::::::::::::::
??pro0/a_0.txt
??::::::::::::::
??00000000000000
??000000000000000
??0000000000000000
??::::::::::::::
??pro0/test_0.txt
??::::::::::::::
??11111111111111111111
??11111111111111111111
??11111111111111111111
??[root@snowli dirtest]# ls pro1
??a_1.txt test_1.txt
??[root@snowli dirtest]# more pro1/*
??::::::::::::::
??pro1/a_1.txt
??::::::::::::::
??00000000000000
??33333333333333
??000000000000000
??55555555555555
??0000000000000000
??::::::::::::::
??pro1/test_1.txt
??::::::::::::::
??22222222222222222222
??11111111111111111111
??00000000000000000000
??11111111111111111111
??
??正面我们创建针对pro0的补丁pro1.patch
??[root@snowli dirtest]# diff -uNr pro0 pro1 > pro1.patch
??补丁内容如下:
??[root@snowli dirtest]# more pro1.patch
??diff -uNr pro0/a_0.txt pro1/a_0.txt
??--- pro0/a_0.txt 2005-01-13 11:59:59.084675792 +0800
??+++ pro1/a_0.txt 1970-01-01 08:00:00.000000000 +0800
??@@ -1,3 +0,0 @@
??-00000000000000
??-000000000000000
??-0000000000000000
??diff -uNr pro0/a_1.txt pro1/a_1.txt
??--- pro0/a_1.txt 1970-01-01 08:00:00.000000000 +0800
??+++ pro1/a_1.txt 2005-01-13 12:00:41.138282672 +0800
??@@ -0,0 +1,5 @@
??+00000000000000
??+33333333333333
??+000000000000000
??+55555555555555
??+0000000000000000
??diff -uNr pro0/test_0.txt pro1/test_0.txt
??--- pro0/test_0.txt 2005-01-13 11:52:56.785874968 +0800
??+++ pro1/test_0.txt 1970-01-01 08:00:00.000000000 +0800
??@@ -1,3 +0,0 @@
??-11111111111111111111
??-11111111111111111111
??-11111111111111111111
??diff -uNr pro0/test_1.txt pro1/test_1.txt
??--- pro0/test_1.txt 1970-01-01 08:00:00.000000000 +0800
??+++ pro1/test_1.txt 2005-01-13 11:54:33.243211224 +0800
??@@ -0,0 +1,4 @@
??+22222222222222222222
??+11111111111111111111
??+00000000000000000000
??+11111111111111111111
??[root@snowli dirtest]#
??
??怎么给程序打补丁,大家可以查一下patch 的联机帮助(man patch)吧。
阅读(2714) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~