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:
Learn the new command ipcalc
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)