![]() |
|
|
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 |
| Clueless about how to lookup and reverse lookup IP addresses under a file!!.pls help | choco4202002 | UNIX for Advanced & Expert Users | 0 | 08-26-2008 02:28 PM |
| Lookup file | mohan705 | Shell Programming and Scripting | 4 | 08-05-2008 05:22 AM |
| Lookup on a file | ukatru | Shell Programming and Scripting | 4 | 07-31-2008 02:25 AM |
| Lookup with a file | pavan_test | UNIX for Dummies Questions & Answers | 5 | 07-21-2006 11:57 AM |
| 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 |
|
|
|
||||
|
Multiple file lookup using awk
I want to lookup filea with fileb,filec and filed. If entry in filea exist in fileb and filec mark Y and then if entry in filea exist in filed mark as Y. Final output should have all the entries from filea. Quote:
Code:
nawk -F"|" 'NR==FNR{a[$1];next} $1 in a{print $1} filea fileb
|
|
||||
|
no. i will not because you are not putting in effort. always look up the manual or google if you don't know anything. this page. there is example of using while loop.
|
|
||||
|
Quote:
Here is my effort: Code:
BEGIN {FS=","}
for (i=0;i< ARGC;i++)
{ARGV[i]=="fileb"{b[$1]++}
ARGV[i]=="filec"{c[$1]++}
ARGV[i]=="filed"{d[$1]++}
ARGV[i]=="filea"{if (($1 in b ) && ( $1 in c) && ($1 in d)) print $1,"Y" OFS
else
if (($1 in d) && !($1 in c) && !($1 in b)) print $1 OFS,"Y"
else
if (($1 in b) && ($1 in c) && !($1 in d)) print $1,"Y"OFS
else print $1 OFS OFS
}} OFS=","
command used : nawk -f awkfiles.awk fileb filec filed filea Here is the error: Quote:
Requirement: Field 1 Filed2 Field 3 $1 of filea|"Y" if $1 of filea exist in fileb and filec| "Y" if $1 of filea exist in filed Output needed: abc,Y, def,, ghi,,Y jkl,,Y Your help is appreciate in fixing this. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|