cp /etc/passwd passwd_old
cat /etc/passwd| sed -e '4d' -e '6c no six line' > passwd_new
[root@mhc regular]# diff passwd_old passwd_new
4d3
< adm:x:3:4:adm:/var/adm:/sbin/nologin
6c5
< sync:x:5:0:sync:/sbin:/bin/sync
---
> no six line
[root@mhc regular]# ls test1
a.txt c.txt
[root@mhc regular]# ls test2
a.txt b.txt
[root@mhc regular]# diff test1 test2
只在 test2 存在:b.txt
只在 test1 存在:c.txt
制作补丁
diff -Naur passwd_old passwd_new > passwd.patch
更新
[root@mhc regular]# patch -p0 < passwd.patch
patching file passwd_old
恢复
[root@mhc regular]# patch -R -p0 < passwd.patch
patching file passwd_old