In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Shell outputs odd lines and even lines of the file respectively.
Awk
[root@114 ~] # awk 'NR%2==0' test.log output even number
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 output odd lines
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'nterterp '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'ptern '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 '1mm 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 '2cm 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'1x 2p 'where 1 represents firest line,2, represents interval step, output line = 1x 2n, odd line
Sed '2cm 2p' output line = 2x 2n, even lines
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.