The UNIX and Linux Forums  

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
how to fetch substring from records into another file smriti_shridhar Shell Programming and Scripting 25 12-01-2008 03:38 AM
how to scan a sequential file to fetch some of the records? manmeet Shell Programming and Scripting 1 10-28-2008 06:30 PM
fetch substring from html code scarfake Shell Programming and Scripting 2 05-29-2008 10:55 PM
How to fetch data from a text file in Unix shikhakaul Shell Programming and Scripting 4 01-25-2008 11:20 AM
Reading special characters while converting sequential file to line sequential Rajeshsu High Level Programming 2 07-10-2006 03:38 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-29-2008
manmeet manmeet is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 51
How to sca a sequential file and fetch some substring data from it

Hi,
I have a task where i need to scan second column of seuential file and fetch first 3 digits of that column

For e.g. FOLLOWING IS THE SAMPLE FOR MY SEQUENTIAL FILE

AU_ID ACCT_NUM CRNCY_CDE
THHSBC001 30045678 THB
THHSBC001 10154267 THB
THHSBC001 10278976 USD
THHSBC001 72876276 THB

In this, i need fetch 300, 101, 102, 728 let us say them ID
I need to fetch them sequentially like, first fetch 300 and also i need to compare this with a DB table (Look up table)which looks like

ID SRC Country Code

300 OHC INM
101 OHC SGH
102 OHC MYH

if those ID from sequential file is present in look up table then i need to fetch the whole record and put that into a separate sequential file named same as country code of look up table.

so in this e.g., ID that is fetched from sequential file is 300 and it is also present into look up table then whole record from the sequential file should go into another sequential file named as INM ( country code corresponding to 300)

Please can anybody help me with this ASAP...

it will be really appreciated..

Thanks
  #2 (permalink)  
Old 10-29-2008
freelong freelong is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 38
Hi,
There are tons of this kind of questions in this forum, why not just search and learn a little bit.

Here is the code:
Code:
awk 'NR==FNR {_[$1]; next}
        substr($2, 1,3) in _ {print $0}
        ' lookup_filename sequential_filename > output_filename
  #3 (permalink)  
Old 10-29-2008
manmeet manmeet is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 51
Thanks ......
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 05:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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