sed command copy screen

Source: Internet
Author: User

Working principle
Syntax format

Working principle
SED is a non-interactive stream editor. The so-called non-interactive, refers to the use of SED can only enter editing commands at the command line to edit the text, and then view the output on the screen, while the so-called flow editor refers to the SED each time only from the file (or input) read into a line, and then the row to specify the processing, and output the result to the screen (unless you cancel the screen output and do not explicitly use the Print command), and then read in the next line. The entire file is processed row by line and then output line by row.
Let's take a look at the working process of SED.
The SED is not processed directly on the original input, but instead it is placed into the buffer, the contents of the buffer are processed, and the original file is not written back (unless the output is redirected by the shell to save the result), but is output directly to the screen. The SED maintains two buffers during operation, one is the active "pattern space" and the other is the auxiliary "staging buffer (holding space)". In general, whenever you run sed,sed first load into the mode space, after processing the output to the screen, and then the second pack into the mode space to replace the original content in the mode space, and then processing, and so on.
In general, the staging buffer is not available, but there are special commands to exchange data between the pattern space and the staging buffer, which is described later in this article. Because all the operations of the SED on the text are carried out in the buffer, no damage is done to the original file.

Syntax format
sed [options] ' command ' file (s)
sed [-options] [' Commands '] filename
Where command part format is [address 1, Address 2] commands [parameters]
[Address-range] [Sed-command] or
[Pattern-to-match] [Sed-command]

The address range can be a number that represents a line number, or it can be a comma-delimited range of two digits, including these two lines. The range can be a number, a regular expression, or a combination of both.
The Pattern-to-match here can also be seen as an address, which is the line number of all rows that match the specified pattern.
command commands must appear, parameters are optional according to the command
Sed prints each line by default
Note that there is no space between the address range and the SED command, and if a space is added, SED ignores it. Parameter-n is used to cancel the default output. By default, SED reads every line into the pattern space, regardless of whether it is processed, to output the contents of the schema space to the screen before reading the next line. The parameter-n can be used to cancel this default output, and the specified line is output to the screen only when the user uses the command p. If you do not use the parameter-N and execute the p command on the specified line, the rows will be printed two times.

sed command copy screen

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.