Sponsored Content
Top Forums Shell Programming and Scripting Multiple file lookup using awk Post 302320290 by pinnacle on Wednesday 27th of May 2009 02:21:49 PM
Old 05-27-2009
Quote:
Originally Posted by vgersh99
instead of while/getline combo for reading the files, you could could use a separate combos of FILENAME/ARGV and read the files into arrays. Checking the content of 'filea' in multiple read-in arrays should be straight-forward.
Search the forums for the terms mentioned above and it should give you enough as a starting hint.
Good luck.
All,

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:
nawk: syntax error at source line 2
context is
>>> for <<< (i=0;i< ARGC;i++)
nawk: bailing out at source line 2

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.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

file Lookup using awk

Hi All, I have two files file1 and file2(lookup file).I need to map more than one keyfields of file1 with file2.how can we achieve it using awk. file1(max 2.2 million records) -------------------------- 680720|680721|077 680720|680721|978 680721|680722|090 file2(no idea about the... (1 Reply)
Discussion started by: jerome Sukumar
1 Replies

2. UNIX for Advanced & Expert Users

Clueless about how to lookup and reverse lookup IP addresses under a file!!.pls help

Write a quick shell snippet to find all of the IPV4 IP addresses in any and all of the files under /var/lib/output/*, ignoring whatever else may be in those files. Perform a reverse lookup on each, and format the output neatly, like "IP=192.168.0.1, ... (0 Replies)
Discussion started by: choco4202002
0 Replies

3. UNIX for Dummies Questions & Answers

Multiple Column print after lookup using NR==FNR (awk)

foo.txt FAMID IID AFF SEX Group AgeCat Dis1 Dis2 Dis3 Dis4 Dis5 Dis6 Dis6 AMD0001 Mayo_49542 1 2 AMD 8 1 1 1 1 1 1 1 AMD0002 Mayo_49606 1 1 AMD 3 1 1 1 1 ... (7 Replies)
Discussion started by: genehunter
7 Replies

4. UNIX for Dummies Questions & Answers

Help with AWK - Compare a field in a file to lookup file and substitute if only a match

I have the below 2 files: 1) Third field from file1.txt should be compared to the first field of lookup.txt. 2) If match found then third field, file1.txt should be substituted with the second field from lookup.txt. 3)Else just print the line from file1.txt. File1.txt:... (4 Replies)
Discussion started by: venalla_shine
4 Replies

5. Shell Programming and Scripting

Combined sed+awk for lookup csv file

have written a combined sed+awk to perform a lookup operation which works but looking to enhance it. looking to match a record using any of the comma separated values + return selected fields from the record - including the field header. so: cat foo make,model,engine,trim,value... (6 Replies)
Discussion started by: jack.bauer
6 Replies

6. Shell Programming and Scripting

awk to print field from lookup file in output

The below awk uses $3 and $4 in search as the min and max, then takes each $2 value in lookup and compares it. If the value in lookupfalls within the range in searchthen it prints the entire line in lookup/ICODE]. What I can't seem to figure out is how to print the matching $5 from search on that... (4 Replies)
Discussion started by: cmccabe
4 Replies

7. Shell Programming and Scripting

awk to lookup section of file in a range of another file

In the below, I am trying to lookup $1 and $2 from file1, in a range search using $1 $2 $3 of file2. If the search key from file1 is found in file2, then the word low is printed in the last field of that line in the updated file1. Only the last section of file1 needs to be searched, but I am not... (6 Replies)
Discussion started by: cmccabe
6 Replies

8. Shell Programming and Scripting

awk to lookup value in one file in another range

I am trying to update the below awk, kindly provided by @RavinderSingh13, to update each line of file1 with either Low or No Low based on matching $2 of file1 to a range in $2 and $3 of file2. If the $2 value in file1 matches the range in file2 then that line is Low, otherwise it is No Low in the... (3 Replies)
Discussion started by: cmccabe
3 Replies

9. Shell Programming and Scripting

awk to lookup stored variable in file and print matching line

The bash bash below extracts the oldest folder from a directory and stores it in filename That result will match a line in bold in input. In the matching line there is an_xxx digit in italics that (once the leading zero is removed) will match a line in link. That is the lint to print in output.... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. Shell Programming and Scripting

awk conditional operators- lookup value in 2nd file

I use conditional operators alot in AWK to print rows from large text files based on values in a certain column. For example: awk -F '\t' '{ if ($1 == "A" || $1 == "C" ) print $0}' OFS="\t" file1.txt > file2.txt In this case every row is printed from file1 to file2 for which the column 1... (5 Replies)
Discussion started by: Geneanalyst
5 Replies
Font::TTF::GPOS(3)					User Contributed Perl Documentation					Font::TTF::GPOS(3)

NAME
Font::TTF::GPOS - Support for Opentype GPOS tables in conjunction with TTOpen DESCRIPTION
The GPOS table is one of the most complicated tables in the TTF spec and the corresponding data structure abstraction is also not trivial. While much of the structure of a GPOS is shared with a GSUB table via the Font::TTF::Ttopen INSTANCE VARIABLES
Here we describe the additions and lookup specific information for GPOS tables. Unfortunately there is no one abstraction which seems to work comfortable for all GPOS tables, so we will also examine how the variables are used for different lookup types. The following are the values allowed in the ACTION_TYPE and MATCH_TYPE variables: ACTION_TYPE This can take any of the following values a The ACTION is an array of anchor tables o Offset. There is no RULE array. The ADJUST variable contains a value record (see later in this description) v The ACTION is a value record. p Pair adjustment. The ACTION contains an array of two value records for the matched two glyphs. e Exit and Entry records. The ACTION contains an array of two anchors corresponding to the exit and entry anchors for the glyph. l Indicates a lookup based contextual rule as per the GSUB table. MATCH_TYPE This can take any of the following values g A glyph array c An array of class values o An array of coverage tables The following variables are added for Attachment Positioning Subtables: MATCH This contains an array of glyphs to match against for all RULES. It is much like having the same MATCH string in all RULES. In the cases it is used so far, it only ever contains one element. MARKS This contains a Mark array consisting of each element being a subarray of two elements: CLASS The class that this mark uses on its base ANCHOR The anchor with which to attach this mark glyph The base table for mark to base, ligature or mark attachment positioning is structured with the ACTION containing an array of anchors corresponding to each attachment class. For ligatures, there is more than one RULE in the RULE array corresponding to each glyph in the coverage table. Other variables which are provided for informational purposes are: VFMT Value format for the adjustment of the glyph matched by the coverage table. VFMT2 Value format used in pair adjustment for the second glyph in the pair Value Records There is a subtype used in GPOS tables called a value record. It is used to adjust the position of a glyph from its default position. The value record is variable length with a bitfield at the beginning to indicate which of the following entries are included. The bitfield is not stored since it is recalculated at write time. XPlacement Horizontal adjustment for placement (not affecting other unattached glyphs) YPlacement Vertical adjustment for placement (not affecting other unattached glyphs) XAdvance Adjust the advance width glyph (used only in horizontal writing systems) YAdvance Adjust the vertical advance (used only in vertical writing systems) XPlaDevice Device table for device specific adjustment of horizontal placement YPlaDevice Device table for device specific adjustment of vertical placement XAdvDevice Device table for device specific adjustment of horizontal advance YAdDevice Device table for device specific adjustment of vertical advance XIdPlacement Horizontal placement metric id (for Multiple Master fonts - but that's all I know!) YIdPlacement Vertical placement metric id XIdAdvance Horizontal advance metric id YIdAdvance Vertical advance metric id CORRESPONDANCE TO LAYOUT TYPES
Here is what is stored in the ACTION_TYPE and MATCH_TYPE for each of the known GPOS subtable types: 1.1 1.2 2.1 2.2 3 4 5 6 7.1 7.2 7.3 8.1 8.2 8.3 ACTION_TYPE o v p p e a a a l l l l l l MATCH_TYPE g c g c o g c o METHODS
read_sub Reads the subtable into the data structures $t->extension Returns the table type number for the extension table $t->out_sub Outputs the subtable to the given filehandle $t->read_value($format, $base, $lookup, $fh) Reads a value record from the current location in the file, according to the format given. $t->read_delta($offset, $base, $lookup, $fh) Reads a delta (device table) at the given offset if it hasn't already been read. Store the offset and item in the lookup cache ($lookup->{' CACHE'}) $t->read_anchor($offset, $base, $lookup, $fh) Reads an Anchor table at the given offset if it hasn't already been read. $t->fmt_value Returns the value format for a given value record $t->out_value Returns the output string for the outputting of the value for a given format. Also updates the offset cache for any device tables referenced. AUTHOR
Martin Hosken Martin_Hosken@sil.org. See Font::TTF::Font for copyright and licensing. perl v5.16.3 2011-10-13 Font::TTF::GPOS(3)
All times are GMT -4. The time now is 11:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy