/wyfs02/m02/73/49/wkiom1x5isgbnd98aacvjrggyge101.jpg "/>8.R command:the R command is a read command. SED uses this command to add the contents of a text file to a specific location in the current file. 650) this.width=650; "style=" Float:none; "title=" 27.png "alt=" wkiom1x5isgiiyizaafqdelvwzc614.jpg "src="/HTTP/ S3.51cto.com/wyfs02/m02/73/49/wkiom1x5isgiiyizaafqdelvwzc614.jpg "/>Some special commands for 9.sed
Sed and awk
Background
When designing a script, you may need to modify the script, such as deleting or replacing some keywords. This method of dynamically modifying files during script execution is called Stream editing. A tool with stream editing capabilities is called stream editor ). Sed is a leader in this field and can complement bash's shortcomings. In addi
Sed Structure Analysis
Sed/awk provides many tutorials, most of which are examples of teaching materials, or grammar textbooks.
After learning SED and awk, the results are learned, which is easy to confuse and the syntax is easy to confuse.
This article mainly explains the s
all lines starting with 11$: Line Tail Locator:/11$/matches all lines ending with 11: Save the lookup string for reference in the replacement string: s/333333/**/g Symbol Representative Find string.X\{m\}: Continuous m xX\{m,\}: At least m xX\{m,n\}: At least m, but not more than n xAWK: is a programming language tool for working with text. The language of the awk utility is similar to the Shell programming language in many ways, although
protected] ~]# cg-c ' root ' 1.txt2[[email protected] ~]# cg-a 2-n ' root ' 1.txt1:root:x:0:0:root:/root:/bin/bashgrep sed is a matching rule that supports {1,3}, which means repeating the preceding characters 1 to 3 times. But awk belongs to a more complicated scripting language.Words, in it () and {} have special meanings, so we want to use these symbols, we need to give them out of righteousness, you ma
-----------------------------Overview-----------------------------------
The
Linux Text Processing tool (the following are commands and tools, and only as a display, not as a modification action)
grep (filtering, but does not support regular expressions)Egrep (regular expression support)Sed (row filter)awk (column filtering)
-
the concept of regular expressions
Regular Expressi
Basic use of Awk and SedYou can call sed and awk in the same way. The command line is as follows:Command [options] script filenameLike almost all unlx programs, sed and awk can get input from standard input and send output to standard output. If filename is specified, the in
grep, sed and awk are quite useful!Gerp Find, sed edit, awk analyzes and processes it based on content.awk (keyword: analysis processing)Parsing of one line of processing awk ' condition type 1{action 1} condition type 2{action 2} ' filename,
a/tmp/fstab.3;650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M00/73/9D/wKiom1YCOMajYsnnAABloVsv4Wg148.jpg "height=" 123 "/>(4) Echo a file path to the SED command, take out its base name, and further, take out its path name;650) this.width=650;
] ruby] # sed-n '/ruby/p ' ab | Sed ' s/ruby//g ' #删除rubyInsert[[email protected] ruby] # sed-i ' $a bye ' ab #在文件ab中最后一行直接输入 "Bye"[email protected] ruby]# Cat ABHello!Ruby is me,welcome to my blog.EndByeDelete a matching rowSed-i '/Match string/d ' filename (note: If the match string is a variable, you need "" instead of ". Remember as if it were)Replace a strin
:/:/sbin/nologin[[email protected]/]# ifconfig | awk '/inet/{print "(#从ifconfig的输出中抽取含inet的行并打印第二域)[[email protected]/]# ifconfig | awk '/inet/{print $} ' | awk-f: ' {print $} ' (#在上面的基础上再抽取, this command allows you to get the IP address of the machine directly)Common command syntax for sedSED is a non-interactive text flow editor. It edits the text copy of the e
Common basic usage features of Find grep sed awk under LINUXJust to make yourself a higher standard, this is the beginning of a 6-month small white advanced road!Learning Linux Basic commands these days is a bit of a crime, especially for files looking for this piece. All I want to put some of the practical parameters I think commonly used to summarize, the big God do not spray ha ...Please advise, the litt
\+\)/[--\1--] [\2]/g ' list[--line--] [200]Line3 100Line4 100Line5 700Line5 800Line6 50Line7 350multiple sed combinations,[Email protected]:~# sed ' s/\ (\w\+\) 2\ (\w\+\)/[--\1--] [\2]/g ' list | sed ' s/line7/tttt/g '[--line--] [200]Line3 100Line4 100Line5 700Line5 800Line6 50TTTT 350AwkAwk is so powerful that I'm not listed here for space reasons, and I can se
Common basic usage features of Find grep sed awk under LINUXJust to make yourself a higher standard, this is the beginning of a 6-month small white advanced road!Learning Linux Basic commands these days is a bit of a crime, especially for files looking for this piece. All I want to put some of the practical parameters I think commonly used to summarize, the big God do not spray ha ...Please advise, the litt
word and replaces it with [], result: [This] [was] [an] [example]echo this was digit 7 in a number | Sed '/digit \ ([0-9]\)/\l/' #参数 \1 (number 1) converts digit 7 to 7---------------------------------------------------------------Text=helloecho Hello World | Sed "s/$text/hello/" #输出结果HELLO World---------------------------------------------------------------Text clutter and return to normal (replace space,
/rc5.d/: S70spice-vdagentd-------------------Instance:1. Statistics TCP Connection StatusCopy the code code as follows:# Netstat-na | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '/^tcp/Filter out lines that start with TCP, "^" for regular expression usage, ... First, this is to filter out lines that start with TCP.S[]An array named S is defined, and in awk, array subscripts usually start at 1 ins
Title: SED/awk equivalent code to Unix Commands
From: www.chinaunix.net thank you very much
Equivalent code of SED and Unix commands:
-------------------------------------------------------------------------------cat | sed ':'cat -s | sed '/./
to er, that is, lovablelover.
The characters X {m}, X {M,}, and X {m, n} repeat: m times, at least m times, at least m times, not more than N timesO {5, 10} matches 5 ~ 10 o strings
| OrEcho "Tom and Jerry" | sed-r's/(Tom) and (Jerry)/\ 2 and \ 1 /'Echo "Tom G1, G2, G3 Jerry" | cut-d ""-F2Echo "ABC Def" | sed-r's/([A-Z] +) ([A-Z] +)/\ 2 \ 1 /'Echo "ABC Def" | sed
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