Sed is an online editor that processes a single line of content at a time. When processing, the currently processed rows are stored in a temporary buffer called pattern space, followed by the SED command to process the contents of the buffer, and after processing is done, the contents of the buffer are sent to the screen. then the next line is processed, so it repeats until the end of the file. The contents of the file do not change unless you use the-I option or redirect the store output. SED is mainly used to automatically edit one or more files, to simplify the repeated operation of the file, to write the conversion program and so on.
There are a few points to note:
(1) Use variable as the address of the file line, need to add single quotation mark
Line=5
Sed-n ' $LINE ' s$^[[:space:]]*$ $p ' sed_test.txt
(2) using SED to write to a blank file, first use echo "" >blank.txt, then use sed to write the file, and finally delete the blank line.
Linux sed command