当前位置:网站首页>awk从入门到入土(5)简单条件匹配
awk从入门到入土(5)简单条件匹配
2022-07-04 08:38:00 【奇妙之二进制】
我们之前一直在提,awk的使用语法如下(我想你已经很熟悉了):
awk [options] ‘pattern {Action}’ file1 file2 ···
对于options(选项)而言,我们使用过-F选项,也使用过-v选项。
对于Action(动作)而言,我们使用过print与printf,之后的文章中,我们还会对Action进行总结。
对于Pattern(模式)而言,我们在刚开始学习awk时,就介绍了两种特殊模式,BEGIN模式和END模式,但是,我们并没有详细的介绍”模式”是什么,怎么用,而此处,我们将详细的介绍一下awk中的模式。
“模式”这个词听上去文绉绉的,不是特别容易理解,那么我们换一种说法,我们把”模式”换成”条件”,可能更容易理解,那么”条件”是什么意思呢?我们知道,awk是逐行处理文本的,也就是说,awk会先处理完当前行,再处理下一行,如果我们不指定任何”条件”,awk会一行一行的处理文本中的每一行,如果我们指定了”条件”,只有满足”条件”的行才会被处理,不满足”条件”的行就不会被处理。这样说是不是比刚才好理解一点了呢?这其实就是awk中的”模式”。
再啰嗦一遍,当awk进行逐行处理的时候,会把pattern(模式)作为条件,判断将要被处理的行是否满足条件,是否能跟”模式”进行匹配,如果匹配,则处理,如果不匹配,则不进行处理。
看个小例子&
边栏推荐
猜你喜欢
Bishi blog (13) -- oral arithmetic test app
DM8 tablespace backup and recovery
Azure ad domain service (II) configure azure file share disk sharing for machines in the domain service
L1 regularization and L2 regularization
ctfshow web255 web 256 web257
What sparks can applet container technology collide with IOT
ArcGIS application (XXII) ArcMap loading lidar Las format data
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 007 - production and setting skybox resources
Mouse over to change the transparency of web page image
es6总结
随机推荐
Moher College phpmailer remote command execution vulnerability tracing
1、卡尔曼滤波-最佳的线性滤波器
Unity-写入Word
团体程序设计天梯赛-练习集 L1-006 连续因子
Leetcode 23. Merge K ascending linked lists
C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,Gauss-Jordan消去法,源代码
转:优秀的管理者,关注的不是错误,而是优势
PHP session variable passed from form - PHP
Webapi interview question summary 01
C # implements a queue in which everything can be sorted
The right way to capture assertion failures in NUnit - C #
snipaste 方便的截图软件,可以复制在屏幕上
Leetcode 146. LRU cache
How to play dapr without kubernetes?
Four essential material websites for we media people to help you easily create popular models
Use preg_ Match extracts the string into the array between: & | people PHP
埃氏筛+欧拉筛+区间筛
What should I do if there is a problem with the graphics card screen on the computer
DM8 command line installation and database creation
Comparison between sentinel and hystrix