1. Exercises
For a file, 1 to 5 lines delete the line with English, 6 to 10 lines delete the English characters inside;
2. Analysis
This requirement, with the SED command can be solved, mainly used to match the knowledge of replacement.
3. Scripts
#!/bin/bashsed -n ‘1,5p‘ a.txt | sed ‘/[a-zA-Z]/d‘sed -n ‘6,10p‘ a.txt | sed ‘s/[a-zA-Z]//g‘sed -n ‘11,$p‘ a.txt
The first two requirements, you must use line number matching. The primary sed is a stream-editing processor that receives input data one line at a line and then processes it.
The-N and-p options work together to output only matching content. So, in the first two lines the meaning of the command is equivalent, after matching to the corresponding line, only the rows are processed, and then through the pipeline, they passed to the following SED command processing.
The SED command in the third line is to output the screen directly from the text that is not processed. Thus, on the screen, it is equivalent to completely processing the entire text content.
Daily shell exercise (--sed) processing