![]() |
|
|
grep unix.com with google
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Our Members | 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. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
AWK: read values from file1; search for values in file2
I have read another post about this issue and am wondering how to adapt it to my own, much simpler, issue. I have a file of user IDs like so: Code:
333333 321321 546465 ...etc I need to take each number and use it to print records wherein the 5th field matches the user ID pulled from the first file. Naively, I thought success was a while loop away. Code:
while read line;do awk -F'\t' '$5 ~ /line/ {print $0}' line="$line" FULL-RECORDS.txt;done < USER-ID.txt > new.txt
As you can see, the second file contains full records ( tab delimited ) for each user like so ( sanitized for your pleasure ): Code:
"CHUCKLES, WARREN P." 04 555 FAKE ADDRESS (302) 555-5555 545465 120 "CORMORANT, HOPPY P." 04 565 FAKE ADDRESS (302) 555-5555 545466 120 Advice? Thanks for reading! Bubnoff |
| Bits Awarded / Charged to vgersh99 for this Post | |||
| Date | User | Comment | Amount |
| 12-01-2009 | Bubnoff | N/A | 10 |
|
|||
|
BRILLIANT ~~
My AWK knowledge has been raised to a new level and my problem was
solved. Thanks!!! Bub |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search, replace string in file1 with string from (lookup table) file2? | gstuart | Shell Programming and Scripting | 9 | 06-08-2009 07:11 AM |
| Read each word from File1 and search each file in file2 | clem2610 | Shell Programming and Scripting | 8 | 04-23-2009 09:13 AM |
| Search values between ranges in File1 within File2 | cgkmal | Shell Programming and Scripting | 4 | 01-31-2009 06:37 PM |
| awk/sed search lines in file1 matching columns in file2 | floripoint | Shell Programming and Scripting | 1 | 12-17-2008 11:36 PM |
| Korn Shell Script - Read File & Search On Values | run_unx_novice | Shell Programming and Scripting | 2 | 06-15-2005 08:20 AM |