diff ,patch补丁制作及打补丁工具

文本比较,补丁制作及打补丁工具:
diff ,patch
示例:
cp 两个/etc/rc.d/init.d/functions 文件,修改其中2,
[root@localhost mark.raid0.1]# cp functions functions.2
[root@localhost mark.raid0.1]# ls
functions functions.2
vim functions.2,添加信息如:mark[http://www.gray-track.com/]
[root@localhost mark.raid0.1]#vim functions.2
开始传统比较
[root@localhost mark.raid0.1]# diff functions functions.2
5c5
< #
---
> # Mark Blog$[http://www.gray-track.com/]
[root@localhost mark.raid0.1]#
-u 选项查看,把最新配置文件放在后面,这个文件相当于补丁程序
[root@localhost mark.raid0.1]# diff -u functions functions.2
--- functions 2015-04-08 02:58:49.919994380 -0700 (文件时间戳)
+++ functions.2 2015-04-08 03:01:42.831994276 -0700
@@ -2,7 +2,7 @@
#
# functions This file contains functions to be used by most or all
# shell scripts in the /etc/init.d directory.
-# 少一行
+# 多一行 Mark Blog$[http://www.gray-track.com/]

TEXTDOMAIN=initscripts
[root@localhost mark.raid0.1]#


将最新的补丁保存为./functions.bak
[root@localhost mark.raid0.1]# diff -u functions functions.2 > ./functions.bak
[root@localhost mark.raid0.1]# ls
functions functions.2 functions.bak
将./functions.bak补到 patch functions中
[root@localhost mark.raid0.1]# patch functions < functions.bak
patching file functions
[root@localhost mark.raid0.1]#
head查看下头部
[root@localhost mark.raid0.1]# head functions
# -*-Shell-script-*-
#
# functions This file contains functions to be used by most or all
# shell scripts in the /etc/init.d directory.
# Mark Blog$[http://www.gray-track.com/]

TEXTDOMAIN=initscripts

# Make sure umask is sane
umask 022
[root@localhost mark.raid0.1]#

在比较,就没有什么不同了
[root@localhost mark.raid0.1]# diff functions functions.2
[root@localhost mark.raid0.1]#

完成!

patch复杂用法,详情请看下期!

0 分享

您可以选择一种方式赞助本站

支付宝扫码赞助

支付宝扫码赞助

日期: 2015-04-10分类: Sys Basics

标签: linux基础

发表评论

仅有一条评论

加载中,请稍候...
  1. 控企鹅
    April 10th, 2015 at 11:14 am

    这个不错。可以制作后门包。。收藏下。。