![]() |
|
|
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 |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
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
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|