Wednesday, 31 May 2017

How to use Diff Command in Linux

diff command compares two different files and reports the difference. The
output is very cryptic and not straight forward to read.

Syntax: diff [options] file1 file2

What was modified in my new file when compare to my old file?
The option -w in the diff command will ignore the white space while
performing the comparison.
In the following diff output:

o The lines above ---, indicates the changes happened in first file in the
 diff command (i.e name_list.txt).

o The lines below ---, indicates the changes happened to the second
 file in the diff command (i.e name_list_new.txt). The lines that
belong to the first file starts with < and the lines of second file starts
with >.

# diff -w name_list.txt name_list_new.txt

2c2,3
< John Doe
---
> John M Doe
> Jason Bourne

No comments:

Post a Comment

What is PS2 - Continuation Interactive Prompt in Linux

A very long command can be broken down to multiple lines by giving \ at the end of the line. The default interactive prompt for a multi-lin...