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 tool
This article describes the most commonly u
SED: line editing toolssed [option] ... ' Address edit command ' filename ...Address format:Start_line[,end_line] #需要编辑的行号/patten1/,/patten2/#第一次被pattern1匹配到的行开始 to all rows between the end of the line to which the first pattern2 is matched;/pattern/#对被pattern匹配到的行进行相关操作No address #对全文进行操作The pattern above is usually a regular expressionEdit commandP: PrintD: DeleteI text: Above the line, text is an example of what is inserted:
awk ToolsAwk is also a good data-processing tool. Awk tends to divide a line into several fields to deal with the processing of an entire line compared to SED. As a result, awk is quite suitable for small data processing. The usual mode of operation for awk is this:[[email p
Summary: The regular expressions for the two commands are distinguished by ' single quotation marks.The output variable name is quoted in single quotes, and the output variable value is quoted in double quotes, which is generally common in bash scripts.To use a variable value in a bash script, enclose the double quotation markawk usage:Reference URL: http://www.cnblogs.com/xudong-bupt/p/3721210.htmlCommand form:awk [-f|-f|-v] ' begin{}//{command1; Command2} end{} ' fileSeparate the Product_uuid
1.The question:The sample text is as follows:AaaaabbbbbcccccdddAaaaabbbbbcccccThe following results are expected:Aaaaa|bbbbb|ccccc|dddAaaaa|bbbbb|cccccMatching requirements:I want a "|" to be inserted between every 5 characters, and if the number of characters in the line is exactly 5, the "|" is not inserted at the end of the line.Jie Yi:' s# (. { 5}) #\1| #g' t1shell.txt |sed 's#|$# #g'aaaaa|bbbbb|ccccc| DDDAAAAA|cdefg|bbbbc| ccccdddddSolution Two
#/bin/bash# sort the data inside the text awk ' begin{rs= ', '}{print $0}end{} ' C + + Sorts large amounts of data inside the text (shell,c++,fopen,awk,sed)
Reprinted from Jrckkyy final edit Zengzhaonong
Using shell variables in sed and awk----------------------------------------------x=mmSed ' s/ab/' $x '/g ' B.COrSed ' s/ab/' "$x" '/g ' B.CSed ' s/' "$val" '//' UrfileThe most recent process of anticipation, using bash scripts, requires the use of shell variables in the script's sed and
Grepqueries/extracts rows that contain specific keywords from the data file.SedUsed primarily for substitution processing of specific strings in a data file.CutCuts the contents of the selected column (-F num) or the character (-c) by the specified delimiter (-D).AwkOften used to display only specific fields, or to rearrange the order of fields in a row.JoinA file used to combine fields with a common key value in a record.---------------------------------------------------------------I'm a split
Command usage: Displays the contents of 20 to 30 lines of the file-------------------------------------------------SeqGenerating sequencesSEQ >[file name] Generates a sequence of 1~100 rows:123...100Note:The sequence starts at 1 only when the maximum value is defined aboveSEQ 0 100 starts from 0, sequence order follows natural number orderSeq-1 100 starting from-1:-1 0 1 ... 100-------------------------------------------------SedStream Editor Stream editorsSed-n ' 20,30p ' [file name] prints 20
Regular expressions: Regular expressions are a set of rules and methods that are defined for processing a large number of strings.Regular expressions are widely used in almost all languages (e.g. Java, C, C + +, PHP, Python, etc.)============ Basic Regular =============^ Match with what to start with, ^w matches content starting with W$ match with what ends, $w matches content ending with W^$ Matching Blank lines. Represents and can only represent any one character\ escape character, such as \.
Directory:First, the operation Principle of shell programSecond, Shell common skills1. Command history2. Command aliases3. Command Reference4. File name Wildcard5. Common shortcut keys6. Complement function7. Input and output redirection and piping8. Interact with user commands9. Script specification establishment and execution10.bash Common Options11. Command Status ResultsContinue to be found in ...Three, the common knowledge points description1. Variables1) Variable type2) Local Variables3) E
This thing, if do not often operate, sincerely after a period of time forget clean. To master proficiency, it is necessary to practice more, there is nothing to say. Cool shell Nets Two articles good ha:Sed:Http://coolshell.cn/articles/9104.htmlAwk:Http://coolshell.cn/articles/9070.htmlMU class network Video materials:The regular expression of shell programming: http://www.imooc.com/learn/378Novice study, it is recommended to practice and repeatedly read the information.A simple example of
Use the shell command in combination with grep awk sed sort # when processing a ticket, select the desired ticket first. Here, select the AAA ticket, then sort by corresponding fields # The-k parameter is generally used, and + 0.4 is generally used when the file name is relatively regular
the beginning and end of a word
Demo results650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/85/A8/wKiom1erK9KTmXhgAAB0GJE0uWc768.png-wh_500x0-wm_3 -wmp_4-s_1012968505.png "title=" 3.png "alt=" Wkiom1erk9ktmxhgaab0gje0uwc768.png-wh_50 "/>Example:Use the following command to find the No and standard IP numbersGrep-e ' [1,2][0-9]{0,2}\. [0-9] {1,3}\. [0-9] {1,3}\. [0-9] {1,3} ' exeLooking for a standard mobile phone numberGrep-e ' 1[34578][0-9]{9} ' exeSearch for No and stand
Jul 03:21/root/oldboy.txt 1.5 write up the previous directory CD command 1) go to the previous level directory CD .. 2) View multiple top-level directory CDs: /.. /.. /.. /.. /.. /.. / 3) Enter the current directory CD Chapter 2nd the use of the Three Musketeers of Linux 2.1 grep (filter) Three Musketeers old three Method 1-grep [[emailprotected] data]# #grep filter to display what you want or not [[emailprotected] data]# grep "Oldboy"/dat A/test.txt Oldboy [[emailprotected] data]# gr
[[Email protected]~]# cat File1 2 5 8 9[[email protected]~]# cat file |xargs-n1[[email protected]~]# xargs-n 1 This article is from "Kaka West" blog, please be sure to keep this source http://whnba.blog.51cto.com/1215711/1853501Methods such as grep, SED, and awk implement row-to-column
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.