![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| file Lookup using awk | jerome Sukumar | Shell Programming and Scripting | 1 | 08-30-2007 03:28 AM |
| getting particular text after grep from lookup file | napolayan | UNIX for Dummies Questions & Answers | 10 | 10-20-2006 10:52 AM |
| Lookup with a file | pavan_test | UNIX for Dummies Questions & Answers | 5 | 07-21-2006 10:57 AM |
| reverse lookup file problem | Westy564 | IP Networking | 2 | 01-09-2004 02:55 PM |
| file lookup | gillbates | UNIX for Dummies Questions & Answers | 6 | 12-12-2003 02:04 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Lookup on a file
Hi,
I have the following requirement. I have one lookup file which contains 15 columns and 7000 records. Ex: 123,MEDICA,134,145,1178,123,678,345,2345,HP,COL,K12,SR,OX,78919 I have input file which contains 14 columns and 20 million records.Some times the record count is more than 20 million. I need to match the first 14 columns with 14 columns in the lookup file and if matches i need the 15 the column. Can any one please help me and give me some code which will process very effeciently. I need to finish this process less than 20 minutes. Can any one please suggest me how can we acheive this using ksh or even perl script is also good. Thanks |
|
||||
|
Thanks for your reply.And there is small change in the requirement.
Lookupfile 123,MED,134,145,(117-200),<ANY>,678,345,234,HP,CO,K12,SR,OX,7891 InPutFile 123,MEDICA,134,145,118,123,678,345,2345,HP,COL,K12,SR,OX Here column highlited in red in the input text file which falls in between 117-200(range comparision) and column highlighted in rose colour in the input file equals <ANY> in the lookupfile.Can you please tell me how to acheive this by using the above code. |
|
||||
|
I used the above script and i am getting the following output
#!/usr/bin/perl -w $lookupfile=$ARGV[0]; open(LOOKUP,"<$lookupfile") || die "Argh: $lookupfile : $!"; while (<LOOKUP>) { if (/(.*)\,([^\,])$/) { $lookup{$1}=$2; } } close (LOOKUP); while(<STDIN>) { $key=$_; chomp $key; if ($match=$lookup{$key}) { print "${key},${match}\n"; } else { print "${key},ERROR!\n"; } } scripname.pl lkpfile.txt < inputfile.txt 123,123,123,123,123,123,123,123,123,123,123,123,123,123,ERROR! cat lkpfile.txt 123,123,123,123,123,123,123,123,123,123,123,123,123,123,uma cat inputfile.txt 123,123,123,123,123,123,123,123,123,123,123,123,123,123 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|