当前位置:网站首页>[one day learning awk] Fundamentals
[one day learning awk] Fundamentals
2022-06-30 12:46:00 【Programmer Xiao Li】
1. awk What is it ?
awk yes linux Environment , A syntax sugar similar to regular expressions in code .
2. awk Statement composition of

awk The sentence of is mainly divided into three parts :
One is BEGIN, This part mainly completes initialization , Only once , not essential .
Then there is the repeated part ,repeat. This section performs a corresponding operation for each match .
And finally END part , Generally, the closing operation is completed , Only once , not essential .
3. Try to use BEGIN
First , We create a text ,vi marks.txt
1) Learnfk Physics 80
2) Toolfk Maths 90
3) Chromefk Biology 87
4) Poemfk English 85
5) Nesfk History 89Let's take a look at the content first :

We try to use awk sentence , stay marks.txt Add a sentence before the text "This is the title."
awk 'BEGIN{printf "This is the title.\n"} {print}' marks.txtThis sentence is actually printed in front of the text , explain BEGIN Is the first execution , And only once

4. No, BEGIN The sentence of
We can execute repeated statements directly
awk '{print}' marks.txt
5. Write command to script
vi command.awk

And then use awk -f command.awk marks.txt perform

The effect is the same as direct execution .
6. Command specifies the variable
Use -v Variable can be specified , for example
awk -v name=Bob 'BEGIN{printf "hello, %s\n", name}{print}' marks.txt
We can use it directly awk The specified variable .
边栏推荐
- JMeter之性能测试流程及性能测试关注点
- The format of RTSP address of each manufacturer is as follows:
- How to use the plug-in mechanism to gracefully encapsulate your request hook
- Substrate 源码追新导读: 5月中旬: Uniques NFT模块和Nomination Pool
- 项目中遇到一个有趣的事情
- 腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?
- Generate entity classes from SQL Server database tables through EF core framework
- 【一天学awk】运算符
- Hisilicon 3559 sample parsing: Venc
- Idea has a new artifact, a set of code to adapt to multiple terminals!
猜你喜欢

【MySQL】MySQL的安装与配置

What is the principle of spectral confocal displacement sensor? Which fields can be applied?
![[target tracking] |pytracking configuring win to compile prroi_ pool. pyd](/img/ac/1e443164e57c4f34ddd1078de9f0d2.png)
[target tracking] |pytracking configuring win to compile prroi_ pool. pyd

Qt读写Excel--QXlsx工作表显示/隐藏状态设置4

New function of SuperMap iserver11i -- release and use of legend

Pinda general permission system (day 7~day 8)

Analysis of the whole process of common tilt data processing in SuperMap idesktop

MySQL composite query

【一天学awk】基础中的基础

Determining the subject area of data warehouse construction
随机推荐
60 divine vs Code plug-ins!!
SuperMap iServer11i新功能----图例的发布和使用
【一天学awk】运算符
How to use the plug-in mechanism to gracefully encapsulate your request hook
Sqlserver query code is 936 simplified Chinese GBK. Should I write 936 or GBK?
Hisilicon 3559 universal platform construction: introduction to YUV format
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (II)
【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(二)
Redis的基本操作的命令
pyqt5界面的布局与资源文件的载入
市值蒸发650亿后,“口罩大王”稳健医疗,盯上了安全套
【 surprise】 la vitesse de téléchargement de Thunderbolt n'est pas aussi rapide que celle de la machine virtuelle
【目标跟踪】|pytracking 配置 win 编译prroi_pool.pyd
第十三章 信号(三)- 示例演示
Scratch drawing square electronic society graphical programming scratch grade examination level 2 true questions and answers analysis June 2022
Videos are stored in a folder every 100 frames, and pictures are transferred to videos after processing
MySQL判断执行条件为NULL时,返回0,出错问题解决 Incorrect parameter count in the call to native function ‘ISNULL‘,
Google refutes rumors and gives up tensorflow. It's still alive!
7 lightweight and easy-to-use tools to relieve pressure and improve efficiency for developers, and help enterprises' agile cloud launch | wonderful review of techo day
力扣之螺旋矩阵,一起旋转起来(都能看懂)