1.grep[-cinvABC] ‘word‘ filename
-C: Print the number of lines that meet the requirements
--color: Display Color
-I: Ignore case (Ignore)
-N: Output (number) at the same time as the line that meets the requirements
-V: Print rows that do not meet the requirements (take reverse)
-A: followed by a number (with or without a space), for example, –A2 to print the line that meets the requirements and the following two lines (after)
-B: followed by a number, such as –B2, to print the line that meets the requirements and the above two lines (before)
-C: followed by a number, such as –C2, to print the line that meets the requirements and two rows above and below
-e: Allow extended regular Expressions (extended regular expression)
-R: Traversal
Note: "." means any one character eg:grep-e ' ro.t ' 1.txt= egrep ' ro.t ' 1.txt, can filter out root
". *" means 0 or more arbitrary characters, eg:grep-e ' ro.*t ' 1.txt= egrep ' ro.*t ' 1.txt, can filter out rot,rosadat,roo...t
"?" Represents 0 or one character followed in front of him, Eg:grep-e ' ro?t ' 1.txt = Egrep ' ro?t ' 1.txt, "O?" You can filter out the Rt,rot (when you think. * What do you mean, manual funny)
"+" denotes one or more of the preceding characters, eg:grep-e ' ro+t ' 1.txt = Egrep ' ro+t ' 1.txt, "o+" can filter rot,root,rooo...t
You can also use this: ... (oo+) 1.txt; ... (OO) {1.txt,{} is a number indicating the number of repetitions
[^a]:[] The ^ in parentheses means except for: Which means to take the opposite and the non
2.sed (Find replacement)
Find:
Sed-n ' NP ' 1.txt lists the first few lines
-N: Cancel default output
Np:n for the first few lines, listing multiple lines can ' 1,10p ', expressed as listing 1-10 rows, ' 5-$ ' lists line fifth to the end of the line
Sed-n '/root/p ' 1.txt lists rows that contain root
Multiple behaviors
Sed-n-E '/root/p '-e ' NP ' 1.txt
-E: Implementing Multiple behaviors
Delete
Sed ' 1,5d ' delete 1-5 rows
Replace
Sed ' s///g ' replacement (this is similar to vim), Eg:sed-r ' 5, $s # ([^:]+) (:. *+:) ([^:]+$) #\3\2\1# ' 1.txt, represented as the end word for replacing line fifth to the last row
-R: Allow extended regular Expressions (extended regular expression)
Note: Because the \ symbol is easy to confuse when it comes to paths, you can use #,@ instead
3.awk
"CentOS" Regular expression