我需要从特定行数中grep数据,如第1,6行

时间:2015-12-01 11:53:04

标签: linux unix

我需要从行号1,然后是6,然后是11&等等。

1- IntraPOP,I'NAL,Active,KOL BE-DS-01 to China NETACT,KOL1bds001,VCFlexA-X5,144.15.21.6 ,341,China NetAct,NA,143.14.45.144,340,
2- IntraPOP,I'NAL,Active,KOL BE-DS-01 to China NETACT,KOL1bds001,VCFlexA-X5,144.15.21.6 ,341,China NetAct,NA,143.14.45.144,340,
3- IntraPOP,I'NAL,Active,KOL BE-DS-01 to China NETACT,KOL1bds001,VCFlexA-X5,144.15.21.6 ,341,China NetAct,NA,143.14.45.144,340,
4- IntraPOP,I'NAL,Active,KOL BE-DS-01 to China NETACT,KOL1bds001,VCFlexA-X5,144.15.21.6 ,341,China NetAct,NA,143.14.45.144,340,
5- IntraPOP,I'NAL,Active,KOL BE-DS-01 to China NETACT,KOL1bds001,VCFlexA-X5,144.15.21.6 ,341,China NetAct,NA,143.14.45.144,340,
6- IntraPOP,I'NAL,Active,KOL BE-DS-02 to China NETACT,KOL1bds002,VCFlexA-X5,144.15.21.7 ,341,China NetAct,NA,143.14.45.144,340,
7- IntraPOP,I'NAL,Active,KOL BE-DS-02 to China NETACT,KOL1bds002,VCFlexA-X5,144.15.21.7 ,341,China NetAct,NA,143.14.45.144,340,
8- IntraPOP,I'NAL,Active,KOL BE-DS-02 to China NETACT,KOL1bds002,VCFlexA-X5,144.15.21.7 ,341,China NetAct,NA,143.14.45.144,340,
9- IntraPOP,I'NAL,Active,KOL BE-DS-02 to China NETACT,KOL1bds002,VCFlexA-X5,144.15.21.7 ,341,China NetAct,NA,143.14.45.144,340,
10- IntraPOP,I'NAL,Active,KOL BE-DS-02 to China NETACT,KOL1bds002,VCFlexA-X5,144.15.21.7 ,341,China NetAct,NA,143.14.45.144,340,
11- IntraPOP,I'NAL,Active,KOL BE-DS-03 to China NETACT,KOL1bds003,VCFlexA-X5,144.15.21.8 ,341,China NetAct,NA,143.14.45.144,340,
12- IntraPOP,I'NAL,Active,KOL BE-DS-03 to China NETACT,KOL1bds003,VCFlexA-X5,144.15.21.8 ,341,China NetAct,NA,143.14.45.144,340,
13- IntraPOP,I'NAL,Active,KOL BE-DS-03 to China NETACT,KOL1bds003,VCFlexA-X5,144.15.21.8 ,341,China NetAct,NA,143.14.45.144,340,

1 个答案:

答案 0 :(得分:1)

awk可以很容易地从第一行开始抓取每五行:

cat file | awk '!((NR-1)%5)' | grep ...

这取行号,减1,并验证它可以被5整除。