September 18, 2006
Unix “Diff” Command
Last week, I released the newest version of Call Log to the Lamson Information Desk. However, when it was released, there was a serious bug that caused the info desk to stop productively functioning. It was getting to the point where nothing was working and we had to roll back an older version of Call Log before that release.
Needing to compare differences in the files, Zach told me about the “Diff” command in Unix which allows you to compare two different files and it will inform you of the changes.
Standard Syntax
[test@www ~]$ diff folder/file.html folder2/file.html
The #’s at the top are the line #’s, the < signifies that the following is from the left file and the > means it is from the right file.
List Syntax
[test@www ~]$ diff -Bbrq folder folder2
This time I am listing all of the files in each directory that are different. Each parameter of diff (right after “-”) will change the output that it gives you.
-B = Ignore changes that just insert or delete blank lines.
-b = Ignore changes in amount of white space.
-r = When comparing directories, recursively compare any subdirectories found.
-q = Report only whether the files differ, not the details of the differences.
It not only shows you the files that are only in one directory, but it shows which files in each are different.
For more information on diff from a UNIX prompt, type: man diff


