Sed stream Editor

Source: Internet
Author: User

Sed stream editor sed is a stream editor ). In sed, pattern space and hold space are two buffers. At the beginning, data is read from the standard input into pattern space and processed and output to the standard output. Hold space is only a buffer for auxiliary processing. Some commands can operate on the hold space buffer, such as H, h, g, and G. Sed [OPTION]... {script-only-if-no-other-script} [input-file]... this is the standard format of the command: Description: sed is a stream editor used to process an input stream. Just like many editors running script editing, sed processes only one line of input, so it is more efficient. However, the role of sed in text filtering in pipelines makes it significantly different from other types of editors. -N, -- quiet, -- silent suppress the automatic output function of pattern space-e script, -- expression = script adds the script to the execution command-f script-file, -- file = script-file command input source is file-I [SUFFIX], -- in-place [= SUFFIX] edit-l N, -- line-length = N set the length of the automatic line feed -- posix disable all GNU extensions-r, -- regexp-extended Application Extensions of the regular expression-s, -- separate treats multiple files as multiple streams-u, -- unbuffered flush less data into the output more frequently each time from the file. If the-e or-f option is not available, the first non-option parameter is run as the sed script. All other parameters are input files. If there is no input file, read from the standard input. Command synopsis this is just a concise sed tutorial zero address COMMAND: label is the label used by the B and t commands # comment until the next line of COMMAND is annotated (or at the end of the-e COMMAND) zero or an address command: = print the current line number a text: Add text, you can use a backslash to wrap I text: insert text, you can use a backslash to wrap q and immediately exit the sed script without processing any more input. However, if automatic printing is not disabled, the current mode space will be printed. Q quit sed immediately. The script does not process any more input. r filename is added to the text R filename read from filename, and Commands which accept address rangesb label Branch to label is read from filaname; if label is omitted, branch to end of script. jump to the label and execute the command. If not, t label If a s // has done a successful substitution since the last input line was read and since the last t or T command, then branch to label; if label is omitted, branch to end of script. from From the last input or the last T/t command, the s replacement command is successfully executed and jumped to the label, to the end T label If no s // has done a successful substitution since the last input line was read and since the last t or T command, then branch to label; if label is omitted, branch to end of script. since the last input or the last T/t command, the s replacement command is not executed successfully, jump to the label, not Yo label, to the end of the c text: Replace text, you can use a backslash to wrap the line d from the next cycle to delete the pattern space D to delete the first line of the pattern space. If there is data in it, otherwise, the input h Copy/append pattern will be read from Space to hold space. g G Copy/append hold space to pattern space. x Exchange the contents of the hold and pattern spaces. l List out the current line in a ''ally unambiguous ''form. explicitly list the current row number n N Read/append the next line of input into the pattern space. p Print the current pattern space. P Print up to the first embedded newline of the current pattern space. w filename Write the current pattern Space to filename. W filename Write the first line of the current pattern space to filename. s/regexp/replacement/Attempt to match regexp against the pattern space. if successful, replace that por-tion matched with replacement. the replacement may contain in the special character & to refer to that portion of the pattern space which matched, and the special escapes \ 1 through \ 9 to refer to the corr Esponding matching sub-expressions in the regexp. replacement is used to replace the regexp-Matched Field. replacement may contain the & character ing string that matches regexp, use \ 1 to \ 9 to represent the matched sub-section y/source/dest/Transliterate the characters in the pattern space which appear in source to the cor-responding character in dest. addresses if one address parameter does not exist, it processes all rows. If there is one address, it processes the row. If there are two Addresses, it processes the rows between the two rows, even if parameter 2 is smaller than parameter 1, if address 2 is a regular expression, it does not match the first parameter line. Add above! Symbol. in the reverse direction, select the first ~ The step starting from line 1 is the row of step $ the last row/regexp/the line that matches this regular expression \ cregexpc c can be any character, same as above, just change the form of addr1, + N from addr1 N rows addr1 ,~ N integer multiple rows of N starting from addr1

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.