In the awk below I am trying to cp and paste each matching line in f2 to $3 in f1 if $2 of f1 is in the line in f2 somewhere. There will always be a match (usually more then 1) and my actual data is much larger (several hundreds of lines) in both f1 and f2 . When the line in f2 is pasted to $3 in f1 , the value in $1 is appended to it at the end of the line with a /test/id/$1_raw.file_fixed.txt . Most of this is static text, except the value from $1 is after the third / . Thank you :).
It still isn't clear to me what you are trying to do, but I assume that the above code is giving errors for trying to divide by an element of an unnamed array and then trying to divide the result of that by a non-numeric string. But, that problem may be hidden by the fact that no value in $2 in f1 (i.e., 0000-yyyy , 1111-xxxx , or the empty string from the 3rd line in f1 ) ever appears as a field in f2 . And, therefore, the condition $2 in id is never true.
And, since there is only one field in every line in f2 , the only array subscripts in the id[] array are complete lines from f2 . Why run a loop from 1 through NF when NF is always 1?
Since you say that the corrected f2 only contains one string, the first part of the code in both awk scripts above:
NR==FNR {for(i=1; i<=NF; i++) id[$i]=$1; next}
could more simply be written as:
NR==FNR {id[$0]=$0; next}
or as:
NR==FNR {id[$1]=$1
which would both produce exactly the same id[] arrays.
Since there are no matching lines, I still can't make any sense of the description of what you are trying to combine from matching lines in the two files???