The use of diff and Vimdif in RHEL 6 Linux shell programming

Source: Internet
Author: User
Tags diff linux

Linux compares the differences of 2 files with two commands:

(1)diff (2)Vimdiff

cp/etc/grub.conf Hello

Add Zhangsan at the end of the hello file

Use diff to compare the differences between 2 files:

[Root@rhel ~]# diff hello/etc/grub.conf

18d17

< Zahnsgan

Vimdiff hello/etc/grub.conf

+--lines:grub.conf generated by anac|+ +--one lines:grub.conf generated by Ana

Splashimage= (hd0,1)/grub/splash.xpm.gz | Splashimage= (hd0,1)/grub/splash.xpm.gz

Hiddenmenu | Hiddenmenu

Title Red Hat Enterprise Linux (2.6.32-27| Title Red Hat Enterprise Linux (2.6.32-2

Root (hd0,1) | Root (hd0,1)

kernel/vmlinuz-2.6.32-279.el6.i6| Kernel/vmlinuz-2.6.32-279.el6.i

initrd/initramfs-2.6.32-279.el6.| Initrd/initramfs-2.6.32-279.el6

Zahnsgan | -------------------------------

Using the diff comparison file shows only the difference lines, and the file is shorter and less difficult to see the file difference.

Using Vimdiff to compare files, open 2 files in a new window, different in red display, it is easy to see the difference between files, if the file is longer than easy to compare.

The diff command is not only this way, we can also use diff to do file patch modifications:

Edit 2 file files, their differences are only on the last line.

To generate a file patch:

This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

To import a file patch into a file:

Note: Command explanation: Update files with old files by patch file, and back up old files.

The backed-up files end with orig.

Related Article

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.