十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
shell分别输出文件奇数行、偶数行
创新互联公司"三网合一"的企业建站思路。企业可建设拥有电脑版、微信版、手机版的企业网站。实现跨屏营销,产品发布一步更新,电脑网络+移动网络一网打尽,满足企业的营销需求!创新互联公司具备承接各种类型的成都网站设计、成都网站制作项目的能力。经过10多年的努力的开拓,为不同行业的企事业单位提供了优质的服务,并获得了客户的一致好评。awk
[root@114 ~]# awk 'NR%2==0' test.log 输出偶数号
2 warning: libgcc-4.4.7-4.el6.x86_64: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
4 Installing filesystem-2.4.30-3.el6.x86_64
6 Installing ncurses-base-5.7-3.20090208.el6.x86_64
8 Installing glibc-common-2.12-1.132.el6.x86_64
10 Installing glibc-2.12-1.132.el6.x86_64
[root@114 ~]# awk 'NR%2==1' test.log 输出奇数行
1 Installing libgcc-4.4.7-4.el6.x86_64
3 Installing setup-2.8.14-20.el6_4.1.noarch
5 Installing basesystem-10.0-4.el6.noarch
7 Installing tzdata-2013g-1.el6.noarch
9 Installing nss-softokn-freebl-3.14.3-9.el6.x86_64
sed
[root@114 ~]# sed -n 'n;p' test.log
2 warning: libgcc-4.4.7-4.el6.x86_64: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
4 Installing filesystem-2.4.30-3.el6.x86_64
6 Installing ncurses-base-5.7-3.20090208.el6.x86_64
8 Installing glibc-common-2.12-1.132.el6.x86_64
10 Installing glibc-2.12-1.132.el6.x86_64
[root@114 ~]# sed -n 'p;n' test.log
1 Installing libgcc-4.4.7-4.el6.x86_64
3 Installing setup-2.8.14-20.el6_4.1.noarch
5 Installing basesystem-10.0-4.el6.noarch
7 Installing tzdata-2013g-1.el6.noarch
9 Installing nss-softokn-freebl-3.14.3-9.el6.x86_64
[root@114 ~]# sed -n '1~2p' test.log
1 Installing libgcc-4.4.7-4.el6.x86_64
3 Installing setup-2.8.14-20.el6_4.1.noarch
5 Installing basesystem-10.0-4.el6.noarch
7 Installing tzdata-2013g-1.el6.noarch
9 Installing nss-softokn-freebl-3.14.3-9.el6.x86_64
[root@114 ~]# sed -n '2~2p' test.log
2 warning: libgcc-4.4.7-4.el6.x86_64: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
4 Installing filesystem-2.4.30-3.el6.x86_64
6 Installing ncurses-base-5.7-3.20090208.el6.x86_64
8 Installing glibc-common-2.12-1.132.el6.x86_64
10 Installing glibc-2.12-1.132.el6.x86_64
sed '1~2p' 其中1,代表firest line,2,代表间隔step,输出行=1+2*N,奇数行
sed '2~2p' 输出行=2+2*N,偶数行