Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

matching-by-key program unstable,any possible reason?

Status
Not open for further replies.

will27

Technical User
Jun 13, 2007
23
0
0
US
Dear all
What follows is a simple awk program with a shell wrapper. The problem is sometimes it works fine and sometime it won't.

##########################################################
for ((i=1990;i<=2006;i++))
do


awk 'BEGIN{FS=OFS="\t"} {if ($2==m) print $1,$3,$4}' m=$i GI> tmpGI
awk 'BEGIN{FS=OFS="\t"} {if ($29==m) print $0}' m=$i BK > tmpMFW

awk 'NR==FNR{ara[toupper($1)]=$0;next} toupper($1) in ara {print $0"\t"ara[toupper($1)]}' tmpGI tmpMFW >> BKGIm


done

##########################################################

where "tmpMFW" has 30 fields, table delimited; and evidently "tmpGI" has 3 fields (for both of them, the matching key is $1). for the same file BK and GI (I found this problem when rerun the same program), the outfile "BKGIm" sometimes has 33 fields and sometimes get only 31 fields, the first 2 fields from "tmpGI" are missing. now it stays 31, there must be something wrong, can anybady suggest what might lurk behind.

Thank You
will
 
I'd guess it's something to do with the input data if you are getting varying results.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top