Arrays 如何比较同一字段中的值?
我有这个输入Arrays 如何比较同一字段中的值?,arrays,unix,awk,Arrays,Unix,Awk,我有这个输入 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 我不知道如何解决这个问题你可以试试: awk -
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
我不知道如何解决这个问题你可以试试:
awk -f chk.awk input.txt
其中chk.awk是:
需要更多信息:有多少可能的值?最重要的是:你尝试了什么?那么你在寻找只有两个字段的行?我怎么能把我的qustin放在horezental formeyes中,找到只有两个字段的行呢。
{
a[$1,$3]++
}
END {
if (!("C","1") in a)
print "the name C has no \"1\" value"
}
$ 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