Text processing the-sed advanced usage of the Three Musketeers

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.