Hi
*
I have two text files which has the file size, timestamp and the file name. I need to compare these two files and get the differences in the output format. Can anyone help me out with this.
*
cat file1.txt 474742 Apr 18 2010 sample.log 135098 Apr 18 2010 Testfile
134282 Apr 18* 2010 lib
1024 Jun 13 17:49 checksum.txt 3768008 Oct 19 11:59 reports
2644541 Oct 19 22:07 feed.log
3768008 Oct 19 22.51 quest
0 Nov 29 10:34 textfile.txt
*
cat file2.txt
474742 Apr 18 2010 sample.log
134282 Apr 18* 2010 lib
135098 May 2010 Testfile
4068258 May 23* 2011 release.txt 4068258 May 23 2011 deploy.log
3768008 Oct 19 11:59 reports
2644541 Oct 19 22:07 feed.log
10430 Nov 29 10:43 textfile.txt
*
Desired output:
Differences between two files:
*
file1: 135098 Apr 18 2010 Testfile
1024 Jun 13 17:49 checksum.txt
3768008 Oct 19 22.51 quest
0 Nov 29 10:34 textfile.txt
*
file2:
135098 May 2010 Testfile
4068258 May 23* 2011 release.txt 4068258 May 23 2011 deploy.log
10430 Nov 29 10:43 textfile.txt
*
I tried using diff but did not the appropriate output. Please help me out.
Thanks & Regards
Sendhil
---------- Post updated at 02:48 PM ---------- Previous update was at 02:45 PM ----------
Please ignore * . typo for space. Where Everett there is * its actually a blank space.
Apologize folks, earlier i posted through mobile lot of typos and auto corrections.
Here is my scenario. I need to write a script to get the differences between two files (file1. txt and file2.txt) in the desired format as mentioned. I would really appreciate your help. Thank you all in advance.
cat file1.txt
474742 Apr 18 2010 sample.log
135098 Apr 18 2010 Testfile
134282 Apr 18 2010 lib
1024 Jun 13 17:49 checksum.txt
3768008 Oct 19 11:59 reports
2644541 Oct 19 22:07 feed.log
3768008 Oct 19 22.51 quest
0 Nov 29 10:34 textfile.txt
cat file2.txt
474742 Apr 18 2010 sample.log
134282 Apr 18 2010 lib
135098 May 2010 Testfile
4068258 May 23 2011 release.txt
4068258 May 23 2011 deploy.log
3768008 Oct 19 11:59 reports
2644541 Oct 19 22:07 feed.log
10430 Nov 29 10:43 textfile.txt
Desired output:
Differences between two files:
file1:
135098 Apr 18 2010 Testfile
1024 Jun 13 17:49 checksum.txt
3768008 Oct 19 22.51 quest
0 Nov 29 10:34 textfile.txt
file2:
135098 May 2010 Testfile
4068258 May 23 2011 release.txt
4068258 May 23 2011 deploy.log
10430 Nov 29 10:43 textfile.txt
---End---
awk 'BEGIN{print "File1"} NR==FNR{a[$0]++;next} {if($0 in a){a[$0]="-1"}else{print}} END {print "\nFile2";for(i in a) { if(a != "-1" ){print i}}}' file2 file1