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
Conclusion
Thought this article, To help you compare different line by line in files.Thanks for reading Linux diff command My blog Effortless Zimbra Mail Management: Unleashing the Power of Linux Commands, How-To, and Bash Scripts I hope this is useful.