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

2023年 7月 16日 77.9k 0

文本比较,补丁制作及打补丁工具:
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复杂用法,详情请看下期!

相关文章

服务器端口转发,带你了解服务器端口转发
服务器开放端口,服务器开放端口的步骤
产品推荐:7月受欢迎AI容器镜像来了,有Qwen系列大模型镜像
如何使用 WinGet 下载 Microsoft Store 应用
百度搜索:蓝易云 – 熟悉ubuntu apt-get命令详解
百度搜索:蓝易云 – 域名解析成功但ping不通解决方案

发布评论