Detailed explanation of linux sed commands and sed commandsIntroduction
Sed is an online editor that processes a row of content at a time. During processing, the currently processed rows are stored in the temporary buffer, called the pattern space. Then, the sed command is u
about the commands entered in the script. There cannot be any blank or text at the end of the command. If there are multiple commands in one line, separate them with semicolons. Comments rows starting with # And cannot span rows.
8. Tips
Use double quotation marks when referencing shell variables in the SED command line, instead of the common single quotation marks. The following is a script to delete the zone segment in the named. conf file based
SED is simple to use, and we can provide SED commands directly on the command line or in the form of text files with SED commands. This tutorial explains the example of calling SED, which is available in both ways:Sed command LineHere's what we can refer to as the order quot
Detailed explanation of linux sed commands and sed commands
Sed is a good file processing tool. It is a pipeline command mainly used for processing by behavior units. It can replace, delete, add, and select data rows, next, let's take a look at the usage of sed.Sed command line format:Sed [-nefri] 'command' input text
Tags: edit content man file File round img ChangeIntroduction to the main contents and principles of SEDSed Stream Processing Editor
SED processes one line at a time, reads a row into a row
SED does not change file content (unless redirected)
Sed
command-line format
sed [options] ' comma
': ' As a delimiter to print all third paragraphs less than the fourth paragraph[Email protected] sed]# awk-f ': ' $3Use ': ' As a delimiter, print the first paragraph and the last paragraph, and the middle with ' @ ' connection (for example, the first line should be the form of ' [email Protected]/bin/bash ')[[email protected] sed]# awk-f ': ' {' Print $ ' @ ' $NF} ' passwdUse ': ' As a delimiter to add t
particular PURPOSE, to the extent permitted by law. GNU sed home page: Installing from source codeSince the GNU SED is part of the GNU program, its source code is free to download. We have seen how to install SED using the Package Manager. Now, learn how to install sed from source code.The installation below applies
not mandatory (some systems promote the use of commas in complex expressions), which can increase the readability of the pattern. Use "-" to denote a range of strings, indicating that the string range starts with the character "-" to the left and ends with the "-" right character. Assuming that you want to match any number, you can use: [0 1 2 3 4 5 6 7 8 9] to match any letter, use: [A-z] indicates a range of letters from a-Z, A-Z.7. Number of occurrences of matching pattern results using/{/}U
found, it is copied to the holding buffer, if the line has an object keyword to swap the mode buffer and keep the cache content after the output mode buffer content, The third command indicates that if the last line is reached, the content of the hold buffer will be output directly.H and H, G and G are two sets of corresponding commandsThe h and H commands are to replace the schema buffer content with the content of the hold buffer, but H is the copy that will be kept in the buffer, and the H i
Chapter 7 Stream editing what is sed selection editor UNIXLinux world leaf, there are many text editors available. For example, the most commonly used VI and emacs. With the most familiar editing tool, you can easily manage and edit tasks in UNIX. For example, VI Chapter 7 Stream editing what is sed selection editor
The UNIX/Linux world has many text editors to c
Chapter 7 stream editing what is sed selection Editor
The UNIX/Linux world has many text editors to choose from. For example, the most commonly used VI and emacs. With the most familiar editing tool, you can easily manage and edit tasks in UNIX.
Editors such as VI and emacs are called interactive editors. The interactive editor is great, but it does not help when we need to complete text processing in the p
did do feelthat I do D O'll miss you muchSearch Match display:Displays the line matching ' Miss ': sed- n '/miss/P' song.txt$ Sed-n '/miss/P'Miss you much10.- NParametersCancel Default OutputWhen the P command above is displayed, the-n parameter is used because the SED defaults to printing the input line on the screen: sed
separate the different strings to match in parentheses, but this is not mandatory (some systems promote the use of commas in complex expressions), which can increase the readability of the pattern. Use "-" to denote a range of strings, indicating that the string range starts with the character "-" to the left and ends with the "-" right character. Assuming that you want to match any number, you can use: [0 1 2 3 4 5 6 7 8 9] to match any letter, use: [A-z] indicates a range of letters from a-Z,
SED is simple to use, and we can provide SED commands directly on the command line or in the form of text files with SED commands. This tutorial explains the example of invoking SED in two ways: sed command line
Here's what we can
"Linux Command Line and shell script programming Daquan" sed advanced multi-line command sed Editor contains three commands that can be used to process multi-line text 1.N: Add the next line in the data stream to create multiple row group to process 2.D: delete a row in a multi-row group 3.P: print the next command n command line of the next command line in the m
'2p'Person.txt102, Zhangyao,cto[[email protected]~]# Sed-n'2,3p'Person.txt102, Zhangyao,cto103, Alex,coo Description: Take the line with SED, the simplest [[email protected]~]# Sed-n'1~2p'Person.txt101, Oldboy,ceo103, Alex,coo the, Feixue,cio[[email protected]~]# Sed-n'P'Person.txt101, Oldboy,ceo102, Zhangyao,cto103, Y
appended, each row must end with a backslash, except for the last line. The last line ends with a quotation mark and a file name.
sed‘/^hrwang/a\>hrwang and mjfan are husband\>and wife‘datafile#如果在datafile文件中发现匹配以hrwang开头的行,则在该行下面追加hrwang and mjfan are husband and wife
6.8 i\ CommandThe I\ command inserts a new text in front of the current line.6.9 c\ CommandSED uses this command to modify an existing text to a new text.6.1
: Swaps the content in the pattern space with the content in the hold space N: Overwrites the next line of the row to the pattern space where the match is fetched, N: Appends the next line of the row to the pattern space, D: Deletes the row in the pattern space, and D: Deletes all rows in the multiline mode space;650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/85/E2/wKiom1eta1exk3UoAAKrutPiBuU199.png "title=" 1470833317496604.png "alt=" Wkiom1eta1exk3uoaakrutpibuu199.png "height=" 555
with cat
.
Matches any line of non-newline characters. such as:/c.t/matches C after the access to any character, then the T
*
Match 0 or any number of characters. If/*cat/matches a string of characters followed by all cat lines
[]
Matches a character within a specified range. Example:/[cc]at/matches cat and Cat
[^]
Matches characters not in the specified range. Example:/[^a-z]/matches a line that is not preceded by a ca
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.