Problem source:http://bbs.csdn.net/topics/360033579
Compare the following two text files of the
same format and write the differences (different records) into a text file.
Content
of 1.txt:
Proto Local
Address Foreign Address State
TCP 111.11.1.111:1975 221.181.70.12:5926 ESTABLISHED
Content
of 2.txt:
Proto Local
Address Foreign Address State
TCP 111.11.1.111:1975 221.181.70.12:5926 ESTABLISHED
TCP 111.11.1.111:1111 169.254.241.33:2222 ESTABLISHED
Content of result.txt with exported data will
be:
Proto Local
Address Foreign Address State
TCP 111.11.1.111:1111 169.254.241.33:2222 ESTABLISHED
esProc script for doing this:
A1: The path where text files are stored.
A2: fns
is the script parameter for storing the two text files, 1.txt and 2.txt, under
comparison. Import the files and sort each of them by all the fields.
A3: The first half line of the code - A2.merge@d(#1,#2,#3,#4)
- gets difference between 1.txt and 2.txt; the second half - A2.rvs().merge@d(#1,#2,#3,#4)
- gets difference beweeen 2.txt and 1.txt. Results will then be merged.
A4:
Export A3’s result to result.txt, which concludes the computation.
No comments:
Post a Comment