Image

Knowledge base → Comparing 2 files in Linux console

[Virtual servers]
Date of publication: 18.10.2023

In this tutorial, we will look at some simple examples of comparing 2 files in the Linux console.

1. Comparison using diff

diff text_file_1.txt text_file_2.txt

Conclusion:

2c2
< Linux Debian 11
---
>Linux Debian 10
4c4
< Some new text line
\ No newline at end of file
---
> This text only in second
\ No newline at end of file

2. Comparison using vimdiff

apt install vim
vimdiff text_file_1.txt text_file_2.txt

3. Comparison using colordiff

apt install colordiff
colordiff text_file_1.txt text_file_2.txt

The output is the same as in option 1, only in color.





No Comments Yet