Three major Linux text processing tools grep sed awkBefore there was said grep today look at the SED commandBrief introductionThe SED stream Editor, a non-interactive editor that processes a single line of content at a time. And the editor does not modify the original file by default if you want to modify the result using shell redirection. By default, all output
Reproduced from here, thanks to the original author
sed ‘s/test/mytest/g‘ example.txt
Indicates that the test text in Example.txt is replaced with mytest
Please note that this command sed ‘s/test/mytest/‘ example.txt
If you do not have g, you will only replace the test with mytest at the beginning of each line.
Http://blog.sina.com.cn/s/blog_a56ef5490101cn58.htmlSed is a good file processing tool, itself is a pipe command, mainly in the behavior of the unit processing, you can replace the data rows, delete, add, select and other specific work, the following first understand the use of SEDThe SED command line format is:sed [-nefri] '
function:SED is a stream editor, which is a very important tool in text processing and can be used perfectly with regular expressions. When processing, the currently processed rows are stored in a temporary buffer called pattern space, followed by the SED command to process the contents of the buffer, and after processing is done, the contents of the buffer are sent to the screen. Proceed to the next line,
Sed appears unknown command: ''' (only for fedora18, other systems do not try, do not know if there is a problem) to solve the sed learning in the past two days, follow your example to practice, but I found some problems. I don't know if it's my fedora18 system. Enter echo you are right | sed \'s/right/wrong/\ '-------
The command is as follows:
1. Sed-n' 1 ~ 2! P'datafile
This command reads the datafile file to the mode space on each two lines, matches the first line in each two lines without printing, and prints the remaining lines to cancel the default output.
2. Sed-n' 1 ~ 2 P 'datafile
This
Sed(Stream Editor) Introduction Sed is a stream editor. It is a pipeline command. It processes text files in the unit of action and can replace, delete, add, and select data; sed does not process text files, but readsMode Space(Memory), and then complete the editing in the mode space, output the editing result to the
Today, in the course of learning Linux, we discovered the SED directive.First, the full name of the SED is: Stream EditorThere are two forms of calling the SED command:sed [options] ' command ' file (s)sed [options]-F scriptfile file (s)Today, I'll talk about the use of the-
Unde R '/dev/disk ' # See mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for more info#s///: Find replacement, its delimiter can be specified, such as s$$$ [email protected]@@@, etc.Replace tag:G: Global SubstitutionW:/path/to/iile: Saves the result of the substitution success to the specified fileP: Show the rows that were successfully replacedFor example: sed ' [email protected]^[[:space:]]@@ '/path/to/file after two @@ represents an
Sed '[address range | mode range]'s/old/new/[Replace tag] 'inputfile
The above sed replacement command syntax:
The address range or mode range is optional. If you do not specify it, sed will perform the replacement operation in the full text.
S: tells sed to perform the rep
option "-I", as4. It is also possible to add two commands together, adding the character "HEAD", "TAIL" to each line of Test.file, and the command: sed '/./{s/^/head/;s/$/tail/} ' test.fileIn fact, the above is OK, spend too much time yesterday, mainly because the file is processed by MySQL from the database extracted from the results of the guide, others gave me after I directly deal with, too brain remna
Sed is an online editor that processes a single line of content at a time. When processing, the currently processed rows are stored in a temporary buffer called pattern space, followed by the SED command to process the contents of the buffer, and after processing is done, the contents of the buffer are sent to the screen. then the next line is processed, so it re
1. the first is the c \ command in sed. The difference between this command and S/XXX/xxxx/g is that C \ can replace all the rows found by the current sed with the specified text
For example, sed-I "/734/C \ hello" Install. Log, replace the entire line containing a string s
Sed is a kind of stream codec, which is a very important tool in text processing, and it can be used perfectly with regular expression, so the work can be remarkable. When processing, the currently processed row is stored in a temporary buffer, called the "Pattern Space" (oattern spaces), then the SED command to process the contents of the buffer, after processin
Text Processing Edit command SEDCommand format:sed [option] ' (intercepted line) [action] ' file nameOption:-N: Only the rows that have been processed by SED are output-e: Allow more than one action to be entered-i:sed the modified result to the fileIntercept line: (1) Enter line number directly(2)/Regular expression/(3) x, y lines, or a regular replacement(4) x,y! Reverse(5) X~y starting from X line, step
expression ERE| A regular expression that matches the before or after of the | symbol ERE Fast|slow (can match the sequence)() matches the regular expression group in square brackets ERE\ (ab\) \ (cd\) [def]*\2\1\ (why\). *\1\ ([[: alpha:]_][[:alnum:]_]*\) = \1\ ([' ']\ '). *\1SED commandsed [option] ' command ' input_fileThe usual option-n lists only those rows that have been processed by SED-E perform
Sed Command Practice$sed-E ' s/people/anything/g ' english_w06.txt find and replace ' people ' in the following materials as ' anything '$ Sed-n '/cooking/p ' english_w06.txt print contains cooking line$ Sed-n '/^some/p ' english_w06.txt print lines that begin with some
1. Sed:stream Editor, Stream editors
is to handle pure ASICC plain text, line-by-line manipulation.
There are two types of editor, line editor and full screen editor
SED: Default does not edit the original file, only the data in the pattern space to do processing, and then. After processing finishes, print the mode space to the screen.
2. Format: sed ' addresscommond ' file ...
Use the sed command to delete the pinyin tone
Sometimes we have the following requirements for document Filtering:
Filter or delete irregular characters in a document, such as Chinese characters.
Replace a letter with a normal letter without a tone, especially a PinYin conversion.
For example, you can create a full pinyin dictionary with the last name. First, go to the Internet to find a common surname
The SED command usage for Shell Scripting Learning notesBasic usage of SEDSed:stream EditorLine EditorSED: Pattern space Stores matched text content in pattern spaceBy default, the original file is not edited, only the data in the pattern space is processed, and then, when the processing is finished, the contents of the schema mode space are displayedSed-N-I: Modify the original file directly-E script-e scr
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.