Stream editor is a text processing tool that can process all editing tasks at a time. Instead of directly modifying the file, it copies the text content to the buffer zone and then edits the content it operates on to the buffer zone. If you want to save the result, you need to redirect the buffer content to the file.
I learned a sed command today and failed to run it. It was very depressing. I tried it for a long time and got it done.
Command: sed 'specify address a \ text' input file
Explanation: This command appends text to the specified position of the input file. If no address is specified, it is appended to the end of each row by default.
The following are my actual operations: (the result is incorrect.) I am very familiar with the practice!
My environment is a UNIX experience center
I want to append the text "sed test" to the next line of the sedtestfile File"
-Bash-3.00 $ ls
Sedtestfile
-Bash-3.00 $ cat sedtestfile
1
2
3
4
5
6
7
8
9
0
-Bash-3.00 $ sed '/6/a \ sed test' sedtestfile
Sed: Command garbled:/6/a \ sed Test
An error occurs. Why can't I try it. Is there a space missing. I cannot do anything about it.
A sudden flash of light. Haha! Successful! You can guess how it works.
-Bash-3.00 $ sed '/6/.)
> SED test (enter the text you want to append here .)
> 'Sedtestfile
-Bash-3.00 $ cat sedtestfile
1
2
3
4
5
6
Sed Test
7
8
9
0