The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need some help..Comparison bluesilo Shell Programming and Scripting 0 02-23-2008 04:43 PM
Comparison of 2 files in UNIX Dana Evans UNIX for Dummies Questions & Answers 32 11-21-2007 07:05 AM
Comparison of two files in awk jerome Sukumar Shell Programming and Scripting 12 07-26-2006 08:16 AM
String Comparison between two files using awk rudoraj Shell Programming and Scripting 7 07-25-2006 11:04 AM
dir comparison help ghazi Shell Programming and Scripting 5 12-20-2004 05:54 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-04-2008
kamal_418 kamal_418 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 2
comparison of 2 files

Kindly help on follows.

I have 2 files. One file contains only one column of mobile numbers. And total records in a file 12 million. Second file contains 2 columns mobile numbers and balance. and total records 30 million. I want to find out balance of each data in file 1 corresponding to file 2. I tried egrep -f but it will take very long time. And also use awk '{OFS="|"}NR<=FNR{a[$1]=$1}NR>FNR{print $1,$2,a[$1]}' a b but its given error after 7 million says long data. Can you provide me other commands. please

Thanks in advance..

Last edited by kamal_418; 08-04-2008 at 05:20 AM..
  #2 (permalink)  
Old 08-04-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
For that amount of data, maybe it would make sense to import the information into a database.

Search this site for NR=FNR for a number of awk solutions to similar problems.
  #3 (permalink)  
Old 08-04-2008
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,355
You can use the join command (input files must be sorted on the first column) :
Code:
join kamal1.dat kamal2.dat
Input file 1 (kamal1.dat) :
Code:
111
222
333
888
Input file 2 (kamal2.dat) :
Code:
000 1000
111 1111
222 1222
444 1444
777 1777
888 1888
999 1999
Output :
Code:
111 1111
222 1222
888 1888
Jean-Pierre.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 03:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0