When you need to compare two txt files, you might be about to try following ways,
1, Create a simple perl or python or php script by yourself.
2, Using google to find out some already existed scripts to do comparation for you.
3, Download some windows softwares to help compare the text files.
But frankly most of your work should be finished in a linux environment. So why not have a try to find out some already existed commands first. You simply can issue a command like this to find which command supplies the expected function:[joseph@admon compare]# man -k compare | grep files
File::Compare (3pm) – Compare files or filehandles
bzcmp [bzdiff] (1) – compare bzip2 compressed files
bzdiff (1) – compare bzip2 compressed files
cmp (1) – compare two files
cmp (1p) – compare two files
comm (1) – compare two sorted files line by line
diff (1p) – compare two files
tiffcmp (1) – compare two TIFF files
zcmp [zdiff] (1) – compare compressed files
zdiff (1) – compare compressed files
[eden@admon files]# comm –help
Usage: comm [OPTION]… FILE1 FILE2
Compare sorted files FILE1 and FILE2 line by line.
With no options, produce three-column output. Column one contains
lines unique to FILE1, column two contains lines unique to FILE2,
and column three contains lines common to both files.
-1 suppress lines unique to FILE1
-2 suppress lines unique to FILE2
-3 suppress lines that appear in both files
–help display this help and exit
–version output version information and exit
Report bugs to <bug-coreutils#gnu.org>.
Please refer to “man comm” and “info comm” for the full documentation. If the info and comm programs are properly installed on your operation system, please follow these links for sample usages:
$ comm -23 allby.peter.sort done.joseph.sort > compared.lines.list
This command will generate a file named “compared.lines.list“, it contains the lines that exist in allby.peter.sort but nonexist in done.joseph.sort.
Pay attention to the suffix “sort”: Before using comm, you need to sort the file first in order.
$ sort allbypeter > allbypeter.sort