当前位置:网站首页>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(模式)作为条件,判断将要被处理的行是否满足条件,是否能跟”模式”进行匹配,如果匹配,则处理,如果不匹配,则不进行处理。
看个小例子&
边栏推荐
- How to get bytes containing null terminators from a string- c#
- Leetcode 146. LRU cache
- @Role of requestparam annotation
- The right way to capture assertion failures in NUnit - C #
- [untitled] 2022 polymerization process analysis and polymerization process simulation examination
- How does Xiaobai buy a suitable notebook
- deno debugger
- The upper layer route cannot Ping the lower layer route
- 团体程序设计天梯赛-练习集 L1-006 连续因子
- Convert datetime string to datetime - C in the original time zone
猜你喜欢

1. Getting started with QT

std::is_ union,std::is_ class,std::integral_ constant

How can we make a monthly income of more than 10000? We media people with low income come and have a look

Openfeign service interface call

ArcGIS application (XXII) ArcMap loading lidar Las format data

snipaste 方便的截图软件,可以复制在屏幕上

go-zero微服务实战系列(九、极致优化秒杀性能)

AcWing 244. Enigmatic cow (tree array + binary search)

Redis sentinel mechanism

一文了解数据异常值检测方法
随机推荐
NPM run build error
yolov5 xml数据集转换为VOC数据集
Moher College phpmailer remote command execution vulnerability tracing
微服務入門:Gateway網關
Const string inside function - C #
Unity-Text上标平方表示形式+text判断文本是否为空
Bishi blog (13) -- oral arithmetic test app
[BSP video tutorial] stm32h7 video tutorial phase 5: MDK topic, system introduction to MDK debugging, AC5, AC6 compilers, RTE development environment and the role of various configuration items (2022-
Redis 哨兵机制
From scratch, use Jenkins to build and publish pipeline pipeline project
How to play dapr without kubernetes?
Parallel shift does not provide any acceleration - C #
埃氏筛+欧拉筛+区间筛
【无标题】转发最小二乘法
Newh3c - routing protocol (RIP, OSPF)
Need help resetting PHP counters - PHP
[attack and defense world | WP] cat
如何通过antd的upload控件,将图片以文件流的形式发送给服务器
SQL statement view SQL Server 2005 version number
Leetcode topic [array] -136- numbers that appear only once