Comparision of two huge unix files - Reconcilation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comparision of two huge unix files - Reconcilation
# 8  
Old 04-22-2011
Quote:
Originally Posted by Suman Singh
Thanks to every one.

But i just want to know why the code which i implemented did not work.

Thanks,
Suman
Maybe because 'If' is not the same as 'if'?
# 9  
Old 04-22-2011
Quote:
Originally Posted by Suman Singh
Thanks to every one.

But i just want to know why the code which i implemented did not work.



Thanks,
Suman
Besides If, you can't use continue outside of a loop, your code does not even run here.
# 10  
Old 04-22-2011
Hi Kevintse,

Even the code posted by you is doing the same thing

awk 'FNR==NR{a[$0]; next}!($0 in a)' File2 File1


I am getting the output as whole of File1.
# 11  
Old 04-22-2011
What OS are you using?
Did you test the code I posted with the data in your first post?
My code works with those data(just dummy data?), and I guess it might be your real data that caused the problem, they might be completely different...
# 12  
Old 04-22-2011
Hi Kevintse,

The OS I am using is AIX 3, SHELL - BASH.

Your Code - awk 'FNR==NR{a[$0]; next}!($0 in a)' File2 File1

I tried to run using ur code but it didnot work.I got the output as whole of File 1.
Your infact my code works if the number of data is less say about 100. I tested for 100 datas, it worked.

While I am tryin it with 150000 data, its showing whole of file1.

The data i am using is same as the sample data I provided. Just the number of datas are more and are different but are of same format.

And Kevintse thanks a lot for the pains u are taking to help me.

Thanks,
Suman.
# 13  
Old 04-23-2011
If some one can help onto my above posted concern, will be very much thankful.


Thanks,
Suman.
# 14  
Old 04-23-2011
Actually both the code snippets are working for me

whats wrong with this (assuming the files are sorted)?
Code:
diff file1 file2 | grep '^<'|sed 's/^< //g'

whats wrong with this? Make sure you give File2 and then File1
Code:
awk 'FNR==NR{a[$0]; next}!($0 in a)' File2 File1

regards,
Ahamed

---------- Post updated at 02:40 PM ---------- Previous update was at 02:36 PM ----------

Also I tested with 200 records using awk and diff code.

regards,
Ahamed

Last edited by ahamed101; 04-23-2011 at 08:09 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing Select Columns from two CSV files in UNIX and create a third file based on comparision

Hi , I want to compare first 3 columns of File A and File B and create a new file File C which will have all rows from File B and will include rows that are present in File A and not in File B based on First 3 column comparison. Thanks in advance for your help. File A A,B,C,45,46... (2 Replies)
Discussion started by: ady_koolz
2 Replies

2. Shell Programming and Scripting

Comparision of two text files

Dear all, I am having two files big files i need an output file as first occurance of file1 field in file2 example: file1:raju ranifile2:raju|123 raju|879 rani|623 rani|253result:raju|123 rani|623pls help me in this regard (3 Replies)
Discussion started by: suryanarayana
3 Replies

3. UNIX and Linux Applications

Unix Shell Scripting : Comparision of two files

Hi, We need to compare a text file File1.txt and config file File2.txt in a way that it checks if the content of File1.txt exists between the range mentioned in File2.cfg. The range here is the range between col1 and col2 of File2.cfg If the content of File1.txt lies between the range of... (12 Replies)
Discussion started by: CFA
12 Replies

4. Shell Programming and Scripting

Comparision of fields in 2 files.

Hi Experts, I have two huge files in the format as shown below.I need to open a file1 and file 2 , cut first 24 characters of file 1 and search if the key exists in file 2 first field (delimted by *). If the value exists , copy the third field from file 2 and replace the 5th field in file 1 .... (4 Replies)
Discussion started by: nua7
4 Replies

5. Shell Programming and Scripting

Date comparision in Unix

Hi All, I would need your help to compare dates in my script. Say if I have the dates in a file I need to comapre these dates with yesterday's date and the dates which are older than yesterday needs to be displayed. Example: 03/22/2012 03/24/2012 03/20/2012 03/21/2012 03/12/2012... (1 Reply)
Discussion started by: pdreddy34
1 Replies

6. UNIX for Advanced & Expert Users

Comparision of two files.

File Structure file1.txt.arch 029429288,1,,,02087400376,N,02087400376,N,0,02087400376,N,0,0,8010,08000151736,U,N,,08000151736,U,20100726111237,20100726111237,0,20100726111651,00004140,16,16,10,N;... (1 Reply)
Discussion started by: ravigupta2u
1 Replies

7. Shell Programming and Scripting

Column comparision in two files

Hi, I need to compare a column in two different csv files file1 xyz.com,2/2/12,a,b,c eg.com,2/2/23,a,b,ga file2 1,2,ua,xyz.com 1,2,ua,abc.com 1,2,ua,eg.com 1,2,ua,easg.com 1,2,ua,zth.com Read all entries in file1(which has 1000+) and compare column1 of file1 with the column4... (13 Replies)
Discussion started by: nuthalapati
13 Replies

8. Shell Programming and Scripting

comparision of string in various files

i want to take position 19-24(only first line) from all files and need to compare any duplication is there or not. If duplication, then i have to print the file names. I have written to take the characters from 19-24 from all files. but how to compare ? ... (1 Reply)
Discussion started by: senthil_is
1 Replies

9. Shell Programming and Scripting

Unix File Comparision

I have a file named file1 which contains numbers in sequence like... 1 2 3 7 8 Then i have file File 2 that contains 4 5 ........so i need to compare both files so that i can find out the missing entry in the sequence is 6.......These files are flat files which contain and so i need to... (5 Replies)
Discussion started by: coolguy01
5 Replies

10. Shell Programming and Scripting

How to perform comparision in unix

I am trying to perform a simple if/else check. if ; then mkdir /wdnet/oracletest else mkdir $CON_DIR fi I guess I don't understand the unix basics about comparisons. My scripts always executes the if, even though my CON_DIR variable is not blank. What am I doing... (5 Replies)
Discussion started by: artfuldodger
5 Replies
Login or Register to Ask a Question