compare 2 files and show count same content.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting compare 2 files and show count same content.
# 1  
Old 02-25-2012
compare 2 files and show count same content.

Code:
$ cat File1
Non HTTP response code:java.net.ConnectException225073X
000000005143329Load time: 402335410224
Non HTTP response code: ava.net.ConnectException206423X
000000005143330Load time: 402305687161
Non HTTP response code: ava.net.ConnectException290212X
000000005143331Load time: 402396601449
Non HTTP response code:java.net.ConnectException278583X
000000005143332Load time: 402357111740

$ cat File2
000000005143329Load time: 402335410224:12022500000562783849
000000005143330Load time: 402305687161:12022500000562783852
000000005143331Load time: 402396601449:12022500000562783856

Code:
result expected:
000000005143329Load time: 402335410224: 402335410224 is OK.
000000005143330Load time: 402305687161: 402305687161 is OK.
000000005143331Load time: 402396601449: 402396601449 is OK.
000000005143332Load time: 402357111740: 402357111740 is Not the same.

Please to advise me.

Thank Very Much.
Lee Ha Jun.
# 2  
Old 02-26-2012
You could use awk:

Code:
awk -F: 'NR == FNR {
  f2[$1, $2]; next
  }
!/HTTP/ {
  printf "%s: %s: %s is %s.\n", $1, $2, $2, \
    ($1, $2) in f2 ? "OK" : "Not the same" 
  }' file2 file1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Compare two files and show the mismatch columns

I need to compare two files and find the mismatch columns in it for csv and fixed width file. Eg: file1 c1,c2,c3,c4<----columnname 1,a,4,d 2,b,5,e 3,c,6,f file2 c1,c2,c3,c4<----columnname 3,x,7,f 2,y,8,e 1,z,9,d output c2,c3<---- mismatch columname a,4 x,7 b,5 or y,8 Ok with... (3 Replies)
Discussion started by: sabzR
3 Replies

2. Shell Programming and Scripting

awk to compare files and count

I am trying to compare 2 files and output the results in two files. The lines that are the same output to concordant.txt while the lines that do not match output to discordant.txt. Is there a way to count the lines after specific text (#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT E1) in each... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

Compare two files and count number of matching lines

Dear All, I would like to compare two files and return the number of matches found. Example File A Lx2 L1_Mus1 L1Md_T Lx5 L1M2 L1_Mus3 Lx3_Mus Lx9 Lx2A L1Md_A L1Md_F2 File B L1_Mus3 L1_Mus3 (3 Replies)
Discussion started by: paolo.kunder
3 Replies

4. Shell Programming and Scripting

Compare file1 header count with file2 line count

What I'm trying to accomplish. I receive a Header and Detail file for daily processing. The detail file comes first which holds data, the header is a receipt of the detail file and has the detail files record count. Before processing the detail file I would like to put a wrapper around another... (4 Replies)
Discussion started by: pone2332
4 Replies

5. Shell Programming and Scripting

Script to compare count of two csv files

Hi Guys, I need to write a script to compare the count of two csv files each having 5 columns. Everyday a csv file is recived. Now we need to compare the count of todays csv file with yesterday's csv file and if the total count of records is same in todays csv file and yesterday csv file out... (3 Replies)
Discussion started by: Vivekit82
3 Replies

6. Shell Programming and Scripting

Compare content between two files

I have two files in unix environment with similer type of contain: Example: File1 File2 Milestone1 Milestone1 Milestone2 Milestone12 Milestone3 Milestone13... (11 Replies)
Discussion started by: Mrinal Mondal
11 Replies

7. Shell Programming and Scripting

To compare the content of two text files

I have two files, sec.txt(1st File) 3172 disp.txt(2nd file) the file name is *********** 45676 Now i want to compare the value in sec.txt file with disp.txt file Excatly i want to compare the value 3172 in first file and 45676 in second file. i want to compare the first line of... (11 Replies)
Discussion started by: rammm
11 Replies

8. Shell Programming and Scripting

Shell Script to compare files, check current date and count

Hello - I have written the following basic shell script to count files, compare files and look for a particular strings in a file. Problem 1: How do I define more than 1 file location? #!/bin/bash #this is a test script FILES=$(ls /home/student/bin/dir1, home/student/bin/dir2)... (0 Replies)
Discussion started by: DallasT
0 Replies

9. Shell Programming and Scripting

Compare two text files and Only show the differences

Hi experts, I'mvery new to shell scripting and learning it now currently i am having a problem which may look easy to u :) i have two files File 1: Start :Thu Nov 19 10:33:09 2009 ABCDGFSDJ.txt APDemoNew.ppt APDemoOutline.doc ARDemoNew.ppt ARDemoOutline.doc File 2: Start... (10 Replies)
Discussion started by: CelvinSaran
10 Replies

10. Shell Programming and Scripting

Compare the content of 2 files

Hi Guys, What is the most effecient way to compare the content of 2 seperate files and extract the result of there is a match? We have 2 separate log files and we are trying to find the common errors from the 2 files. Thanks, Odogbolu98 :( (3 Replies)
Discussion started by: odogbolu98
3 Replies
Login or Register to Ask a Question