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.