Learn awk, you must remember to practice, only in practice to find problems, the following on my experience in learning and practice, summed up the difference between rs,ors,fs,ofs and contact.
One, RS and ors
1,rs is the record delimiter , the default delimiter is \ n, specific usage look down
Copy Code code as follows:
[Root@krlcgcms01 mytest]# cat test1//test file
111 222
333 444
555 666
2,rs default delimiter \ n
)Sed ' s#[^0-9a-z]# #g ' 123Swap the first and last words in the test.txt positionSed-r ' s# (^.*) (:. *:.*:.*:.*:.*:.*/.*/) (. *$) #\3\2\1#g ' Test.txtBash:x:0:0:root:/root:/bin/root (last word with first swap)Sed-r ' s# (^.*) (:. *:.*:.*:.*:.*:.*) (/.*/.*$) #\3\2\1#g ' Test.txt/bin/bash:x:0:0:root:/root:root (the last shell and the first word exchange)Sed ' s#\ (^.*\) \ (: x:.*\) \ (/.*$\) #\3\2\1#g ' test.txt (using de-meaning)-R can omit the caret characterReplace the first number and the la
1.netstatNETSTAT-TNL | grep 443 (see if Port 443 is occupied) root user, with Netstat-pnl | grep 443 (also shows the process PID that occupies the native 443 port). -A (all) show all options, default does not show listen related-t (TCP) only show TCP-related options-U (UDP) only show UDP-related options-n deny display aliases, can display all numbers converted into numbers. Use the IP address directly, not through the domain name server. -L only lists the service status in Listen (listening)-p d
What is awkAwk is a small programming language and command-line tool. (its name is from the first letter of its founder Alfred Aho, Peter Weinberger and Brian Kernighan's surname). It is well suited for log processing on the server, primarily because awk can manipulate files, often building lines in readable text.I say it applies to servers because log files, dump files, or any text-formatted server that terminates dumps to disk can become very large,
This section details the awk built-in functions, which are divided into the following 3 types: arithmetic functions, String functions, other general functions, time functionsFirst, arithmetic function:The following arithmetic function performs the same operation as a subroutine with the same name as the C language:
Name of function
Description
Atan2 (y, x)
Returns the y/x of the inverse tangent.
COS
Advanced awk commandsBuilt-in function mathematical functions
Atan2 (y, x)
Calculate the arc tangent of y/x
Cos (x)
Returns the cosine of x. x is a radian.
Sin (x)
Returns the sine of x. x is a radian.
Exp (x)
Calculate the x power of e
Log (x)
Calculate the natural logarithm of x
Sqrt (x)
Returns the square root of x.
Int (x)
Returns the value of x truncated to an int
1.netstatNETSTAT-TNL | grep 443 (see if Port 443 is occupied)-PNL | grep 443 (also shows the process PID that occupies the native 443 port). -A (all) show all options, default does not show listen correlation -t (TCP) only show TCP-related options -u (UDP) only show UDP-related options -n deny display aliases, Can show that all numbers are converted into numbers. Use the IP address directly, not through the domain name server. -L list only service status with Listen (listening) -p shows the prog
Tags: field action Group font water indent more than a few group elements newLinuxThree Musketeers--Awkdking~ Sharing1.1 awkExecution ProcessAwk reads in the first line of contentdetermine if the conditions in the pattern are met nr>=2(whether to let you enter the gate)if the match executes the corresponding action {Print $}if the condition is not matched, continue reading the next lineContinue reading next linerepeat the process until the last line is read ( EOF:End of field)1.2Records and Fiel
Brief introductionAwk is a powerful text analysis tool, with the search for grep and the editing of SED, which is especially powerful when it comes to analyzing data and generating reports. To put it simply, awk reads the file line-by-row, using spaces as the default delimiter to slice each row, and then perform various analytical processing of the cut.AWK has 3 different versions: AWK, Nawk, and gawk, whic
] 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 string in a matching rowSed-i '/Match string/s/Replace source string/Replace target string/g ' filenameLinux
awk Linux Three Musketeers boss filter, output content, a language. NR Representative Line numberThe first column, the second column, $ A, indicates that a row of NF indicates the last column after the specified delimiter-f Specifies the separator. = = is an assignment = = is the equal meaningWrite to: delimiter, first row in file passwd, 1th, 4 columns, and last column[[email protected] data]# awk-f ":" '
IntroductionAwk is a powerful text analysis tool, with the search for grep and the editing of SED, which is especially powerful when it comes to analyzing data and generating reports. To put it simply, awk reads the file line-by-row, using spaces as the default delimiter to slice each row, and then perform various analytical processing of the cut.AWK has 3 different versions: AWK, Nawk, and gawk, which are
The RS, ORS, FS, OFS meanings behind awk in LinuxOne, RS and ORS where is the difference? We often say that awk is based on the row-and-column manipulation of text, but how do you define "lines"? This is the role of Rs.By default, the value of Rs is \ n. Below is an example to understand the Rs.echo ' 1a2a3a4a5 ' | awk ' {print '} ' 1a2a3a4a5echo ' 1a2a3a4a5 ' |
awk [-F field-separator] ' commands ' input-file (s) where commands is the true awk command, [-F domain delimiter] is optional.Input-file (s) is the file to be processed. In awk, each line in a file, separated by a domain delimiter, is called a domain. In general, the default field delimiter is a space without naming the-F domain delimiterLS-LRT |
About AWKAwk is a powerful report generation tool that can be formatted and displayed on the screen later, based on the information we enter. The so-called format is based on our custom format will be required to display the information more beautiful. Awk was originally completed in 1977 and later published a more powerful awk, called Nwak or gawk. Nawk is working under the Windows operating system, and Ga
Awk1. Domains and records:Takes the first field and begins and ends with the character begin and endYou typically use begin to display variables and preset variables, using end to output the final result.awk ' BEGIN {print ' being '} {print '} ' end {print ' End '} ' file2. conditional operator:The first field, which contains expect, prints the entire lineawk ' {if ($1~/expect/) print $} ' c.sh or awk ' $1~/expect/{print} ' fileExact match: Print only
1. Introductionawk is a command under Linux, and his output of other commands is very powerful for processing files.Compared to grep's lookup, the SED editor, awk is especially strong when it comes to analyzing data and generating reports.Big. In simple terms, awk reads the file line-by-row, slicing each row with a space as the default delimiter, cuttingPart of the analysis process. In fact, he is more like
Tags: logs instruction technology + = First break awk programming loop splayAwk is a powerful text analysis tool, with the search for grep and the editing of SED, which is especially powerful when it comes to analyzing data and generating reports. To put it simply, awk reads the file line-by-row, using spaces as the default delimiter to slice each row, and then perform various analytical processing of the c
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.