Advanced Editing Commands:
h: Overwrite the contents of the pattern space in the hold space h: Append the contents of the pattern space to the hold space h H Copy/append pattern space to hold space g: Overlay content in the hold space into the pattern space g: Append content in the hold space to the pattern space g g copy/append hold space to pattern space. x: Swap the content in the pattern space with the content in the hold space x Exchange the contents of the hold and Pattern spaces. n: Overwrite the next line of the row that matches the match to the pattern space n: Append read to the next line of the row to pattern space n N Read/append the next line of input into the pattern space. d: Delete rows in the pattern space &Nbsp; d delete pattern space. start next cycle. d: Delete all rows in multi-line mode space
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/8B/FE/wKiom1heTtPQa4X9AAAJXGOgE_Q802.png-wh_500x0-wm_3 -wmp_4-s_912803367.png "title=" 1.png "alt=" Wkiom1hettpqa4x9aaajxgoge_q802.png-wh_50 "/>
Example
# sed-n ' n;p '/etc/fstab show even line # sed ' 1! G;h;$!d ' file in reverse order displays the contents # sed ' $!d ' file take out the last line # sed ' $! n;$! D ' file takes two lines after extracting the files; # sed '/^$/d; G ' file deletes all blank lines, and then adds a blank line for all non-blank lines # sed ' n;d ' file shows odd lines # sed ' G ' file adds a blank line behind each line
This article is from the "Homecoming" blog, make sure to keep this source http://sixijie123.blog.51cto.com/11880770/1885817
Text processing the-sed advanced usage of the Three Musketeers