Linux diff command
In this tutorial, I use diff command output on screen. How to compare different line by line in files. How to compare side by side, color , output do not output common lines with diff command.
The content file1.txt file
The output number lines with -u option
The output with default color
The output side by side with -y option
The output side by side and do not output common lines with -y , --suppress-common-lines option
Linux diff command with option in this tutorial
What diff command work?
- compare files line by line
The content file1.txt file
[huupv@huupv huuphan.com]$ cat file1.txtThe content file2.txt file
<####################################>
author: huupv
My Blog: www.huuphan.com
Hello everbody!
<####################################>
[huupv@huupv huuphan.com]$ cat file2.txtThe default compare line by line with diff comand
<####################################>
author: huupv
My Blog: www.devopsrole.com
Hello everbody!
<####################################>
[huupv@huupv huuphan.com]$ diff file1.txt file2.txtThe output as below:
3c3
< My Blog: www.huuphan.com
---
> My Blog: www.devopsrole.com
The output number lines with -u option
[huupv@huupv huuphan.com]$ diff -u file1.txt file2.txtThe output as below:
--- file1.txt 2018-06-03 10:44:24.215928386 +0700
+++ file2.txt 2018-06-03 10:45:08.740499854 +0700
@@ -1,6 +1,6 @@
<####################################>
author: huupv
-My Blog: www.huuphan.com
+My Blog: www.devopsrole.com
Hello everbody!
<####################################>
The output with default color
[huupv@huupv huuphan.com]$ diff -u --color file1.txt file2.txt
The output side by side with -y option
[huupv@huupv huuphan.com]$ diff -y file1.txt file2.txt
The output side by side and do not output common lines with -y , --suppress-common-lines option
[huupv@huupv huuphan.com]$ diff -y --suppress-common-lines file1.txt file2.txt
Linux diff command with option in this tutorial
- -y, --side-by-side : output in two columns
- --suppress-common-lines: do not output common lines
Comments
Post a Comment