I have two files, and I have to take columns I need from both files and merge them together. I'd like to use awk to do this.
So from FileB I need $9->$12. If $4 of FileA matches what is in $12 of FileB, I'd need $1,$2,$3,$5, and $6 from FileA.
Here's what I have so far:
script.awk:
FNR==NR {
blah = $12
gsub(/"/,"",blah); gsub(/;/,"",blah);
array[blah]=$9,$10,$11,$12 ## This breaks here
next
}
{
if ($4 in array) {
print $1,"TransMap","Tcon",$2,$3,$5,$6,".",array[$4]
}
}
I'd run this like: awk -f script.awk fileB fileA So notice that $12 of FileB isn't an exact match -- any matches with $4 would be in this format: "$4"; (hence the gsubs). I need that format as opposed to what's in $4 in the final output, that's why I did it this way.
The array[blah]=$9,$10... line breaks awk (obviously). But I need all 4 of those fields from FileB -- how would I fix that? Online instructions for awk wasn't clear.