Sed (meaning stream editor, from the English "stream editor" the abbreviation) is a command-line program Unix common. Sed used to document or string inside the text after the conversion of a series of editing commands as another output format. Sed is usually used to text matching one or more regular expression processing.

A semicolon (;) can be used as a separate command indicator. Although many restrictions inherent in sed script, a series of SED instruction can add up to the complex programming like Sokoban, Arkanoid, even the computer game Tetris.

Commonly used sed commands
■//p print all the matching "model"
■//d remove all matching rows "mode"
■s - Replace string
■s/Mode / replace text / - will match "mode" rows into "the replacement text"
■The s command default substitution on each row matching, that is to say, if each row has a plurality of match the pattern string, later will not be s conversion. In this case can replace all the matching text using the G command, as follows:
■s/Mode / replace text /g all matching "model" of the string into the "alternate text"

Command line options
■-f - According to the specified sed script commands
■-i - Said the results will be converted directly into the file (if not -i, general sed command does not change the original in content, it will only output to the command line. Of course, the command line output content can also use ">" transferred to another file. )
■-e - In the e behind the text is a regular expression. Some versions do not need to add the e option can also use regular expressions in the command.

Other commands
■sed G - Add a blank line in each row
■sed 'G;G' - Add two blank lines in each row

Started by Arnold at February 01, 2016 - 7:49 AM

Thank you for sharing

Posted by Cliff at January 11, 2017 - 6:10 AM

Learning. Recently by sed and awk, looking classic literacy paste link

Posted by Jeremiah at January 14, 2017 - 6:40 AM

Shell 13 and sed awk 101 to ask completely so that you become a master

Posted by Michelle at January 14, 2017 - 6:52 AM