Using diff

diff is a command-line utility on UNIX-based machines to compare two files. Part of the grading process is automated by using diff. diff takes two filenames as arguments and displays the differences (if any) between the two files. It treats the first file as the original and compares the second file to the first file. Every time diff detects that one or more lines are different between the files, it will output the line number of the first file, a letter and the line number of the second file. The letter is one of the following: If diff detects that a line was changed, it will output the line from the first file, followed by a line with just "---", followed by the line from the second file. It appends "<" and ">" at the beginning of lines to indicate if the line is from the first or second file respectively.
As an example, let's assume that you have the following files:
diffExample1.txt   diffExample2.txt
aaa
bbb
ccc
ddd
eee
fff
ggg
 
aaa
bbb
ddd
e e	  
fff
ggg
hhh	
Executing
diff  diffExample1.txt  diffExample2.txt
yields the following results:
3d2
< ccc
5c4
< eee
---
> e e	  
7a7
> hhh
In this example, diff detected that line 3 in the first file, "ccc" is not present in the second file (at line 2). Additionally, line 5 in the first file is similar to line 4 in the second file ("5c4"). Finally, line 7 in the second file, "hhh", is not found in the first file. Again, if the two files are identical, diff outputs nothing.
Optionally, diff can take a --side-by-side flag to display the results lined up next to each other. Using the same files above and the --side-by-side flag yields the following results:
aaa		aaa
bbb		bbb
ccc	  <
ddd		ddd
eee	  |	e e	  
fff		fff
ggg		ggg
	  >	hhh	
Here, the first file is output on the left, then a column of either "<", "|", ">" or nothing and then the contents of the second file. The "<" and ">" symbols in the middle column have the same meaning as above. The "|" symbol in the middle column indicates that the two lines are similar, but not exact. If there's not a symbol in the middle column, then the line match perfectly. With the --side-by-side flag, longs lines are truncated. To prevent this, use the -W argument with a large number (e.g., -W 170).

Note, if you're working with files created on two different operating systems, e.g., an answer key created on a linux-based machine and your output from a Windows machine, then use the -w argument for diff to ignore differences in whitespace. For example:
diff  -w  answerKey.txt  output.txt