Hack #18 -> Diff Command

Diff command compares two different files and reports the difference.

The output of the diff command 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



The option -w in the diff command will ignore the white space while

performing the comparison.

In the following diff output:

  • The lines above —, indicates the changes happened in first file in

the diff command (i.e name_list.txt).

  • 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


< John Doe

> John M Doe

> Jason Bourne

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s