从数据文件中删除选定的行 - 第 2 部分
这是之前的讨论之后:(从数据文件中删除选定的行)
我有尝试遵循 Fredirk 和 Glenn Jackman 提出的想法,我得出如下代码,仅在这对数字与特定的 creteria 匹配时才打印行。
当我执行代码时,有输出,但它打印所有行,而不是仅打印特定行。
#!/usr/bin/awk -f
BEGIN {
i=0
for (n=1; n<=8; n++) set[i++] = n;
for (n=57; n<=64; n++) set[i++] = n;
for (n=9; n<=49; n+=8) {set[i++] = n; set[i++] = n+7};
}
/^|/{
split($3, res1, "@"); split($6, res2, "@"); #print res1[1], res2[1]
if ( (res1[1] in set) == (res2[1] in set) );
{
print;
next;
}
}
如果有错误的话,谁能帮忙找出错误吗?我可以弄清楚为什么它没有得到。 谢谢。
This is following previous discussion: ( deleting selected lines from data file)
I have tried follow the idea addressed by Fredirk and Glenn Jackman and I come out with the code as below to only print the lines if the pair of numbers are matching specific creteria.
When I execute the code, there is output but it prints all the lines instead only the specific ones.
#!/usr/bin/awk -f
BEGIN {
i=0
for (n=1; n<=8; n++) set[i++] = n;
for (n=57; n<=64; n++) set[i++] = n;
for (n=9; n<=49; n+=8) {set[i++] = n; set[i++] = n+7};
}
/^|/{
split($3, res1, "@"); split($6, res2, "@"); #print res1[1], res2[1]
if ( (res1[1] in set) == (res2[1] in set) );
{
print;
next;
}
}
Could anyone help to find any bug if there is one? I can figure out why it is not getting.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
if
命令后面有一个杂散的分号。如果该条件为真,则您什么也不做。然后打印每一行。There's a stray semi-colon after the
if
command. You do nothing if that condition is true. And then you print each line.