To compare files in Linux, you can use the diff command. Here’s how to do it:
-
Open the Terminal.
-
Navigate to the directory where your files are located. For example:
cd ~/project -
Use the
diffcommand to compare two files. For example:diff file1.txt file2.txt
This command will display the differences between file1.txt and file2.txt.
Example Output:
If there are differences, you might see output like:
1c1
< this is file1
---
> this is file2
Additional Options:
- Use
-ufor a unified format:diff -u file1.txt file2.txt - Use
-ito ignore case differences:diff -i file1.txt file2.txt
Feel free to ask if you need more details or examples!
