Two shell questions (from netizens)

Source: Internet
Author: User


Question 1:

 
[[Email protected] ~] # Cat ABC 1aabbb2ccddd3eefff4gghhh

Change

 
1aabbb2ccddd3eefff4gghhh


Implementation command:

 
Sed '/[0-9]/n; S/\ N //;/[A-Z]/n; S/\ N //; n; D' ABC



Question 2:

 
[[Email protected] ~] # Cat ip.txt 172.16.1.102 255.255.254.0172.16.1.12 255.255.252.0172.16.1.202 255.255.255.0.0172.16.1.212 255.255.128.0172.16.1.21 255.252.0.0172.16.1.22 255.255.255.240.0172.16.1.2 255.248.

Change:

 
172.16.1.102/23172.16.1.12/22172.16.1.202/16172.16.1.212/17172.16.1.21/14172.16.1.22/172.16.1.2/13

Implementation command:

 
Cat ip.txt | while read ip_net; do ipcalc-p $ ip_net; done | paste ip.txt-| SED's/. * = // G'



Record it and keep it later.


PS:

    1. Learn the new command ipcalc

    2. Review sed mode space and reserved space usage

This article from the "lisp O & M path" blog, please be sure to keep this source http://lspgyy.blog.51cto.com/5264172/1545528

two shell questions (from netizens)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.