我有这个输入
name num value
A 1010232 1
A 1010232 2
A 1010232 3
B 2565214 1
B 2565214 2
B 2565214 3
C 6111111 2
C 6111111 3
.
.
O需要这样的输出:
the name C has no "1" value actually
我对解决它的方法一无所知
答案 0 :(得分:2)
你可以尝试:
awk -f chk.awk input.txt
其中chk.awk
是:
{
a[$1,$3]++
}
END {
if (!("C","1") in a)
print "the name C has no \"1\" value"
}
答案 1 :(得分:2)
$ cat file
name num value
A 1010232 1
A 1010232 2
A 1010232 3
B 2565214 1
B 2565214 2
B 2565214 3
C 6111111 2
C 6111111 3
$ awk '
NR>1 { seen[$1,$3]++; names[$1]; vals[$3] }
END {
for (name in names)
for (val in vals)
if (!seen[name,val])
printf "the name %s has no \"%s\" value actually\n", name, val
}
' file
the name C has no "1" value actually