diff—compares two files for differences

diff [-bitw] [-c - cn

Compares two files and displays the differences on a line-by-line bass. Also displays commands that you would use with the ed editor to make changes. (Note: may not be supported by your version of Linux.)

Example A.20.
					diff file1 file2
1c1
<hello there
---
>Hello there.
2a3
>I'm fine.

Explanation

Shows how each line of file1 and file2 differ. The first file is represented by the < symbol, and the second file by the > symbol. Each line is preceded by an ed command, indicating the editing command that would be used to make the files the same.

Get Linux Shells by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.