Back
One of the useful option to find the difference between the files is the diff command.
In the simplest case, diff compares the contents of the two files from-file and to-file. A file name of - stands for text read from the standard input. As a special case, diff - - compares a copy of standard input to itself.
If from-file is a directory and to-file is not, diff compares the file in from-file whose file name is that of to-file, and vice versa. The non-directory file must not be -.
If both from-file and to-file are directories, diff compares corresponding files in both directories, in alphabetical order; this comparison is not recursive unless the -r or --recursive option is given.
diff never compares the actual contents of a directory as if it were a file. The file that is fully specified may not be standard input, because standard input is nameless and the notion of ‘‘file with the same name’’ does not apply.
For examples ;
The screenshots provided for these tools shows the difference between the following two empfile1.txt and empfile2.txt.
$ cat empfile1.txt
John Smith 1001 Sr. Engineer
Peter 1002 Engineer
Fernandous 1003 Sr. Engineer
Kraml 1004 Jr. Engineer
$ cat empfile2.txt
John Smith 1001 Sr. Engineer
Peter 1002 Engineer
Fernandous 1003 Resigned
Kraml 1004 Jr. Engineer
Raj 1005 Engineer
1. Diff Command
This is the traditional way to find out the difference two files is using diff command.
$ diff empfile1.txt empfile2.txt
3c3
< Fernandous 1003 Sr. Engineer
---
> Fernandous 1003 Resigned
5c5
<
---
> Raj 1005 Engineer
2. Colordiff Command
3. Wdiff Command
4. Vimdiff Command
One of the useful option to find the difference between the files is the diff command.
In the simplest case, diff compares the contents of the two files from-file and to-file. A file name of - stands for text read from the standard input. As a special case, diff - - compares a copy of standard input to itself.
If from-file is a directory and to-file is not, diff compares the file in from-file whose file name is that of to-file, and vice versa. The non-directory file must not be -.
If both from-file and to-file are directories, diff compares corresponding files in both directories, in alphabetical order; this comparison is not recursive unless the -r or --recursive option is given.
diff never compares the actual contents of a directory as if it were a file. The file that is fully specified may not be standard input, because standard input is nameless and the notion of ‘‘file with the same name’’ does not apply.
For examples ;
The screenshots provided for these tools shows the difference between the following two empfile1.txt and empfile2.txt.
$ cat empfile1.txt
John Smith 1001 Sr. Engineer
Peter 1002 Engineer
Fernandous 1003 Sr. Engineer
Kraml 1004 Jr. Engineer
$ cat empfile2.txt
John Smith 1001 Sr. Engineer
Peter 1002 Engineer
Fernandous 1003 Resigned
Kraml 1004 Jr. Engineer
Raj 1005 Engineer
1. Diff Command
This is the traditional way to find out the difference two files is using diff command.
$ diff empfile1.txt empfile2.txt
3c3
< Fernandous 1003 Sr. Engineer
---
> Fernandous 1003 Resigned
5c5
<
---
> Raj 1005 Engineer
2. Colordiff Command
3. Wdiff Command
4. Vimdiff Command