Remove the leading space in both files in column 2.
And do yourself a favor and switch to something besides commas for FS
. The Tab char is good because most input screens use tab to move to the next field, so it shouldn't be in your data. The |
char is nice because it is visual and very unlikely to be in your input.
You could build a 'trap' to find records without the right number of fields like this:
awk -F"|" -v expectFldCnt=2 '{
if (NF==expectFldCnt) { print ":everything OK" ; }
else { print "ERR: " NF "!=" expectFldCnt ":" $0 > "errorFile" }
}' \
map.txt relation.txt
IHTH