There are a bunch of host addresses:
A.baidu.com
.
.
.
Z.baidu.com
How to extract the. Baidu.com letters from these data, such as: a b...z?
When you see the problem, you first think about how to generate the file with a script:
Ideas:
1. Definition suffix: suffix= ". baidu.com"
2. Output A-Z character and suffix: {A.. Z} $suffix
3. Space conversion Line
Question 1: How to output A-Z character:
Use {A.. Z} output a b c D ..... space between Z-characters
Problem 2:{a: Z} $suffix Output text: a.baidu.com b.baidu.com.....z.baidu.com, string space delimited. How are line breaks delimited?
Use tr ' \ n '
Test file generation succeeded.
The script is as follows:
#!/bin/bash
suffix= ". Baidu.com"
echo {A.. Z} $suffix |tr ' \ n ' > Hosts.txt
Back to the question: Advance letter A-Z:
Ideas: 1, using awk: delimited string, advance first segment ($)
2. Use tr ' \ n ' to turn line breaks into spaces for a-Z character line display
Awk-f '. ' ' {print $} ' hosts.txt | Tr ' \ n '
Echo
Shell learning process 1-How to output A-Z; spaces, line-wrapping conversions