The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 05-27-2009
pinnacle pinnacle is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 182
Quote:
Originally Posted by vgersh99 View Post
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.