【发布时间】:2017-04-20 16:47:56
【问题描述】:
我有以下两个文件,我需要根据三列的值加入它们,如果不匹配,则在不匹配的列中打印 NA。
cat f1
AAA 0 node4 Activated Unreachable down
AAA 1 node3 Activated Pingable cool
cat f2
AAA 0 node3 XYZ Active
目前我得到的输出不正确:
awk 'NR==FNR{a[$1]=$1;b[$2]=$2;c[$3]=$3;next} $1 in a && $2 in b && $3 in c{print $0}' f1 f2
AAA 0 node3 XYZ Active
期望的输出:
AAA 0 node4 Activated Unreachable down NA
AAA 1 node3 Activated Pingable cool Active
【问题讨论】: