开发者

deleting selected lines from data file-part2

开发者 https://www.devze.com 2023-04-04 00:02 出处:网络
This is following previous discussion: ( deleting selected lines from data file) I have tried follow the idea addressed by Fredirk andGlenn Jackman and I come out with the code as below to only print

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 t开发者_开发百科o find any bug if there is one? I can figure out why it is not getting. Thank you.


There's a stray semi-colon after the if command. You do nothing if that condition is true. And then you print each line.

0

精彩评论

暂无评论...
验证码 换一张
取 消