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
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
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,
] 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
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;
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
:/:/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
/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 '/./
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,
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
. (Begin,end)Action to process the data and place it in {} to indicate (print)(2) Separators, fields, and recordsWhen Awk executes, its browse domain is marked as $1,$2,... $n. This method becomes the domain identifier. $ full for all domains.(3) Illustrate:awk ' {print $} ' test.txt |tee test.out all rows in the output test.txt represent all domainsAwk-f: ' {print $} test.txt |tee Test.out ' Ibid. Just the delimiter for ":"
This book is devoted to the usage of SED and awk, which is very detailed and quite good.
Chapter 4 basic operations
1. awk and SED
2. Difference between SED and Ed
Sed is an implicit global command, while Ed only affects the cur
When you design script, you sometimes need to modify your scripts, such as deleting or replacing certain keywords. Like this practice of dynamically modifying files during script execution, called stream editing. A tool with flow editing capabilities, called the Flow editor. SED is the strong in this respect. In addition, script execution may have to make a report, rendering each field information, awk perf
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.