the domain name statistics return code is greater than or equal to 400 percent, if Youku total 4 lines, a return code greater than or equal to 400 has two lines, that is 50% awk ' { count[$1]++; if ($2>400) above400[$1]++ } end{ for (i in count) { print I, Count[i], above400[i]/count[i] } } ' Example two:Count the percentage of all the error in a fileawk '/error/{err++}end{print err,nr,err/nr*100
Use regular expressions and grep, sed, awk (1), grepawk
Some nonsense:
For regular expressions, I have always been confused. I can see some code. The script contains regular expressions, awk, sed, and I am totally confused. I can't remember how to use it at ordinary times, s
:
# NL/ETC/PASSWD | Sed ' 2i test '
Add two rows to test after the second line
Copy Code code as follows:
# NL/ETC/PASSWD | SED ' 2a test \
> Test '
Replace line:
3. Replace 2-5 lines of content with No 2-5 number
Copy Code code as follows:
# NL/ETC/PASSWD | Sed ' 2,5c No 2-5 number '
4 list 第5-7 lines in/et
Have you ever had to calculate a very large data (hundreds of GB) requirement? Or search inside, or anything else--something that can't be done in parallel. Data experts, I'm talking to you. You may have a 4-core or more core CPU, but our appropriate tools, such as grep, bzip2, WC, awk, sed, and so on, are single-threaded and can only use one CPU core.Borrowing c
: #/sbin/ifconfig eth0 |grep ' inet addr 'Delete the previous part of IPCopy CodeThe code is as follows: #/sbin/ifconfig eth0 |grep ' inet addr ' | Sed ' s/^.*addr://g 'Remove the part of the IP afterCopy CodeThe code is as follows: #/sbin/ifconfig eth0 |grep ' inet addr ' | Sed
http://www.vaikan.com/use-multiple-cpu-cores-with-your-linux-commands/Have you ever had to calculate a very large data (hundreds of GB) requirement? Or search inside, or anything else--something that can't be done in parallel. Data experts, I'm talking to you. You may have a 4-core or more core CPU, but our appropriate tools, such as grep, bzip2, WC, awk, sed , a
|headThe begin {Command} End{command} structure in awk, specifying the operation of the head and tail, different from the general begin END block structureSpecial meta characters in awk: +,? + Match all,? Match a single characterMatch operator: ~,!~//~ match,!~ mismatchHead messages |awk ' $ ~/21:59/' matches 21:59 rows, which is equivalent to the
the most recent time)-ctime: +/-n based on the creation time of the file "in the day dimension, span large;-cmin, Minute Dimension"-atiime: +/-based on the access time of the file "IBID.;-amin, Minute Dimension"-mtime: +/-based on the modified time of the file "IBID.;-mmin minute Dimension"-exec cmd {} \;: The Find command executes the shell command given by the parameter to the matching file, noting "{}" and "\;" There are spaces example: 1, find files created within the day of 1 hours before
Linux Three Musketeers awk, SED, grep1, awk is mainly used to do the breakdown, matching, calculation work2, SED is mainly used to do the replacement (stream processing)3, grep is mainly used to filter out the required textawk (the default delimiter is a space)
Top with awk, medium with SED, standard grep我们都知道,在Linux中一切皆文件,比如配置文件,日志文件,启动文件等等。如果我们相对这些文件进行一些编辑查询等操作时,我们可能会想到一些vi,vim,cat,more等命令。但是这些命令效率不高,这就好比一块空地准备搭建房子,请了10个师傅拿着铁锹挖地基,花了一个月的时间才挖完,而另外一块空地则请了个挖土机,三下五除二就搞定了,这就是效率。而在linux中的“挖土机”有三种型号:顶配awk,中配sed,标配
multi-core CPUs. As soon as you don't care, it's done.GREPIf you have a very large text file, you may do this before:Grep pattern bigfile.txt now you can do this:Cat bigfile.txt | parallel -- pipe grep 'pattern' or:Cat bigfile.txt | parallel -- block 10 M -- pipe grep 'pattern'-Block 10 MParameter. This indicates that each kernel processes 10 million rows-you can use this parameter to adjust the number of
) display of records with multiple criteriaSed-e '/tomcat/' p-e '/2017-03-08/' p-n/var/log/tomcat.logd) Delete the first few lines of records, using the letter DN in single quotes means the first few linesDelete nth row record sed-n ' n ' d file nameDelete the M,n line record sed-n ' m,n ' d file nameDelete last line record sed-n ' $ ' d file namee) Replace chara
grep, sed, and awk are all text processing tools, and although they all have their advantages and disadvantages, one text processing command cannot be completely replaced by another, or three text-processing commands will not appear. In comparison, however, SED and awk are
files in the/var/logs directory that were changed before 7th, and ask them before deleting them;$ find/var/logs-type f-mtime +7-ok rm { } \;5, in order to find all the files belonging to the root group in the system;$find. -group root-exec ls-l { } \;6. The Find command will delete the Admin.log file that contains the digital suffix since the access time in the directory was 7th.This command checks only three digits, so the suffix of the corresponding file should not exceed 999. Build several
grep, SED and awk are three very powerful file processing tools for Linux.Gerp Find, sed edit, awk analyzes and processes it based on content.Now let's find out how these three file processing tools are different (certainly different, or why there are three kinds ...). )
Tags: shellShell Script Learning Summary----sed+grep+awk+ Regular================================================================================First part SED================================================================================I. INTRODUCTION of SEDSED is the stream editor. He is an indispensable tool in te
Study for a period of time, feeling in good condition, the teacher said the class can also be remembered, this is learned (note) the 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0071.gif "alt=" J_0071.gif "/>.In the spirit of the beginning of his mercy, out of the Tao is very simple questions to test their own, not on the machine, handwriting ... It turned out to be tragicQuestion 1: There are 3 lines of text that require the exclusion of intermediate lines, showing lines 1th and 3r
Content directory: Find file lookup grep text Search xargs command line parameter conversion sort sort Uniq eliminate duplicate rows with TR convert cut by column split text paste by column stitching text WC statistic lines and characters tool sed text substitution benefits The lines, words, and characters in the iteration file for the AWK Data flow processing to
Some nonsense:
For regular expressions, I have always been confused. I can see some code. The script contains regular expressions, awk, sed, and I am totally confused. I can't remember how to use it at ordinary times, so I won't summarize it. If you are free, Let's sum up. By the way, we can overcome the weak points of Shell and JS with regular expressions. I plan to write in three articles
Body:
Generally,
Getting started with regular expressions and grep, sed, awk (1)
Some nonsense:
For regular expressions, I have always been confused. I can see some code. The script contains regular expressions, awk, sed, and I am totally confused. I can't remember how to use it at ordinary
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.