当前位置:网站首页>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
边栏推荐
- [teacher Zhao Yuqiang] index in mongodb (Part 1)
- 2022.DAY592
- [teacher Zhao Yuqiang] MySQL high availability architecture: MHA
- 理解 期望(均值/估计值)和方差
- 2022.6.30DAY591
- Apache+php+mysql environment construction is super detailed!!!
- Source insight automatic installation and licensing
- JS implements the problem of closing the current child window and refreshing the parent window
- [teacher Zhao Yuqiang] RDB persistence of redis
- Method of finding prime number
猜你喜欢
【一起上水硕系列】Day 10
[escape character] [full of dry goods] super detailed explanation + code illustration!
[teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
Understand one-way hash function
Solve the problem of automatic disconnection of SecureCRT timeout connection
[Shangshui Shuo series together] day 10
How does win7 solve the problem that telnet is not an internal or external command
[teacher Zhao Yuqiang] Flink's dataset operator
Method of finding prime number
Introduction to redis using Lua script
随机推荐
Final review Day8
卷积神经网络CNN中的卷积操作详解
[video of Teacher Zhao Yuqiang's speech on wot] redis high performance cache and persistence
Apt update and apt upgrade commands - what is the difference?
Complete set of C language file operation functions (super detailed)
Final review (Day2)
NG Textarea-auto-resize
一起上水碩系列】Day 9
2022.7.2day594
Altaro o365 total backup subscription plan
70 shell script interview questions and answers
Redhat7 system root user password cracking
Redhat7系统root用户密码破解
Apache+PHP+MySQL环境搭建超详细!!!
一起上水硕系列】Day 9
QT read write excel -- qxlsx insert chart 5
[teacher Zhao Yuqiang] RDB persistence of redis
Es 2022 officially released! What are the new features?
Personal outlook | looking forward to the future from Xiaobai's self analysis and future planning
Pytorch through load_ state_ Dict load weight