当前位置:网站首页>The programmer shell with a monthly salary of more than 10000 becomes a grammar skill for secondary school. Do you often use it!!!
The programmer shell with a monthly salary of more than 10000 becomes a grammar skill for secondary school. Do you often use it!!!
2022-07-03 05:47:00 【Tell a joke】
List of articles
One 、 Regular expressions
1、 Introduction to regular expressions
Regular expressions describe a pattern of string matching (pattern), It can be used to check whether a string contains some kind of string 、 Replace the matching substring or take a string that meets a certain condition from a string, etc .
The component that builds a regular expression can be a single character 、 Character set 、 character in range 、 Choice between characters or any combination of all these components
2、 Regular expression symbols
① Basic symbols
Symbol | describe |
---|---|
^ | Match the beginning |
$ | Match the end |
[…] | Matches any single character in the set |
[^…] | Negate the set |
. | Match any single character |
* | Match the previous character any number of times |
{n,m} | Match the previous character n~m Time |
{n,} | Match the previous character at least n Time |
{n} | Match the previous character n Time |
② Extended regular compatible regular symbols
Regular sign | describe |
---|---|
\b | Match the boundaries of words |
\w | Match character numeric underscores |
\W | and \w contrary |
\s | Match blanks |
\d | Match the Numbers |
\d+ | Match multiple numbers |
\D | Match non numeric |
3、grep Grammar format
grep Options Matching mode file
Common options :
-v: Reverse match
-i: Ignore letter case
Two 、sed
1、sed What is it? ?
sed Is a non interactive streaming editor , You can add, delete, modify and query text , Mainly used to automatically edit one or more files 、 Simplify file manipulation 、 Write conversion program, etc
2、sed elements of grammar
Format :
· sed [ Options ] ‘[ Locator ] Instructions ’ file name
· sed [ Options ] ‘[ Locator ] Instructions ’
Common options :
-n: Mask default output
-i: Modify the source file directly (sed The source file will not be modified by default , Only the results will be printed )
-r: Support extended regularization
① Line number locator
sed You can use the line number to locate the data content you need to modify
example :sed -n "3p" /etc/passwd // Print /etc/passwd pass the civil examinations 3 That's ok
② Regular locator
sed You can use regular matching to match the data you need , Then edit the corresponding content
example : sed -n "/^root/p" /etc/passwd
③ sed Multi line text processing
Commonly used instructions :
i(insert): Insert
a(append): Additional
r(read): Read the file | Import file content
w(write): file save as | Export file content
3、 ... and 、awk Process control
1、awk What is it? ?
awk Is a language that processes text , Is a powerful text analysis tool , Is a powerful line by line processing software , Read one line at a time , Match the regular and then process , Check input text based on pattern matching , Line by line processing and output , Usually used for re shell Script , Get the specified data . When used alone , Statistics can be made on the text data
2、awk Command format
Format :
· Front order | [ Options ] ‘[ Conditions ]{ Instructions }’
·awk [ Options ] ‘[ Conditions ]{ Instructions }’ file
Common options :
-F: You can specify the separator , The default separator is ( Space or Tab key )
① awk Built-in variables ( Built in variables have special meanings , You can use it directly
Variable | describe |
---|---|
FS | Save or set field separator , for example FS=":" , And -F Function as |
$n | Specify the number of divisions n A field , Such as $1、$3 Separate indication control 1、 The first 3 Column |
$0 | The entire line of text currently read |
NF | Record the number of fields in the current processing line ( Number of columns ) |
NR | Record the number of currently read rows ( Row number ) |
② awk Filtering time
Format : awk ‘BEGIN{} [ Conditions ]{} END{}’ file
- BEGIN{} Process before all lines , Execute... Before reading the first line of text , Generally used to initialize
- {} Deal with line by line , Read the text line by line and perform the corresponding processing ,
- END{} Execute... After processing the last line of text , Generally used to output results
边栏推荐
- Apache+PHP+MySQL环境搭建超详细!!!
- [teacher Zhao Yuqiang] index in mongodb (Part 1)
- Mapbox tasting value cloud animation
- Altaro o365 total backup subscription plan
- [teacher Zhao Yuqiang] use Oracle's tracking file
- [teacher Zhao Yuqiang] use the catalog database of Oracle
- 【一起上水硕系列】Day 7 内容+Day8
- [advanced pointer (1)] | detailed explanation of character pointer, pointer array, array pointer
- 卷积神经网络CNN中的卷积操作详解
- Export the altaro event log to a text file
猜你喜欢
[teacher Zhao Yuqiang] redis's slow query log
How to set up altaro offsite server for replication
Analysis of the example of network subnet division in secondary vocational school
[teacher Zhao Yuqiang] kubernetes' probe
Final review (Day5)
[set theory] relational closure (relational closure related theorem)
Apache+PHP+MySQL环境搭建超详细!!!
[branch and cycle] | | super long detailed explanation + code analysis + a trick game
[teacher Zhao Yuqiang] Cassandra foundation of NoSQL database
Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception
随机推荐
70 shell script interview questions and answers
一起上水硕系列】Day 9
Life is a process of continuous learning
Es 2022 officially released! What are the new features?
期末复习(DAY7)
Use telnet to check whether the port corresponding to the IP is open
Beaucoup de CTO ont été tués aujourd'hui parce qu'il n'a pas fait d'affaires
[untitled]
Analysis of the example of network subnet division in secondary vocational school
期末复习DAY8
Jetson AGX Orin 平台移植ar0233-gw5200-max9295相机驱动
Final review (Day2)
[trivia of two-dimensional array application] | [simple version] [detailed steps + code]
[branch and cycle] | | super long detailed explanation + code analysis + a trick game
Installation du plug - in CAD et chargement automatique DLL, Arx
[advanced pointer (1)] | detailed explanation of character pointer, pointer array, array pointer
为什么网站打开速度慢?
Altaro set grandfather parent child (GFS) archiving
Redhat7系统root用户密码破解
6.23 warehouse operation on Thursday