Linux commands: Patch

Source: Internet
Author: User
Tags diff

A. Patch for Single file:

We take Mkprj.sh.1 and mkprj.sh two files as an example:

[[email protected] tst]# ls
Mkprj.sh.1 mkprj.sh

See the differences between the two files:
[Email protected] tst]# diff mkprj.sh Mkprj.sh.1
20,21c20
< CD $workdir/fornew; mkdir crosstools kernel nfs_root uboot;
< CD $workdir/farsight; mkdir crosstools kernel nfs_root uboot;
---
> CD $workdir/farsight1; mkdir crosstools kernel nfs_root uboot;
23c22
<
---
> CD $workdir/configs2;

1. Make Patch Patches
[[email protected] tst]# diff mkprj.sh mkprj.sh.1 > Mk_patch
2. Patch Patches

[Email protected] tst]# patch mkprj.sh < Mk_patch
Patching file mkprj.sh

Observe two files that are already the same:
[Email protected] tst]# diff mkprj.sh Mkprj.sh.1

3. Uninstall Patch Patches

[Email protected] tst]# patch-r mkprj.sh < Mkpatch
Patching file mkprj.sh

Observing two files, mkprj.sh back to its original appearance.
[Email protected] tst]# diff mkprj.sh Mkprj.sh.1
20,21c20
< CD $workdir/fornew; mkdir crosstools kernel nfs_root uboot;
< CD $workdir/farsight; mkdir crosstools kernel nfs_root uboot;
---
> CD $workdir/farsight1; mkdir crosstools kernel nfs_root uboot;
23c22
<
---
> CD $workdir/configs2;

Second, patch for the directory

How to make patch files for Linux and how to make patcheshttp://blog.csdn.net/zhenwenxian/article/details/8393731

#ls/work/kernel

linux-2.6.22.6 linux-2.6.22.6_jz2440

1. Make Patch Patches

#diff-naur linux-2.6.22.6/linux-2.6.22.6_jz2440/> Linux-2.6.22.6_jz2440.patch

#ls/work/kernel

linux-2.6.22.6 linux-2.6.22.6_jz2440 Linux-2.6.22.6_jz2440.patch

2. Patch Patches

#cd/work/kernel/linux-2.6.22.6

Patch-p1 <. /linux-2.6.22.6_jz2440.patch

3. Remove patch (-R)

Patch- R -p1 <. /linux-2.6.22.6_jz2440.patch

Linux commands: Patch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.