当前位置:网站首页>[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 .
边栏推荐
- SuperMap iServer11i新功能----图例的发布和使用
- 海思3559萬能平臺搭建:獲取數據幀修改後編碼
- Swagger2 automatically generates API documents
- 解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matchin问题
- FlinkSQL自定义UDTF使用的四种方式
- SQLSERVER 查询编码是 936 简体中文GBK,那我是写936 还是写GBK?
- 如何利用AI技术优化独立站客服系统?听听专家怎么说!
- Sqlserver query code is 936 simplified Chinese GBK. Should I write 936 or GBK?
- Redis cache problem
- The format of RTSP address of each manufacturer is as follows:
猜你喜欢

Visual studio configures QT and implements project packaging through NSIS
![[QNX Hypervisor 2.2用户手册]6.2.3 Guest与外部之间通信](/img/ca/9065325ce8882d95fb24c82fb62abc.png)
[QNX Hypervisor 2.2用户手册]6.2.3 Guest与外部之间通信

Building a database model using power designer tools

Android development interview real question advanced version (with answer analysis)

Three ways for flinksql to customize udaf

Efficient elliptic curve point addition and multiplication in scrypt

FlinkSQL自定义UDATF实现TopN

【一天学awk】数组的使用

Hisilicon 3559 developing common sense reserves: a complete explanation of related terms

Four ways for flinksql to customize udtf
随机推荐
Essay: Research on smart home scheme
Analysis of the whole process of common tilt data processing in SuperMap idesktop
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (II)
Dataworks synchronizes maxcomputer to sqlserver. Chinese characters become garbled. How can I solve it
SuperMap iDesktop 常见倾斜数据处理全流程解析
问卷星问卷抓包分析
论文解读(AGC)《Attributed Graph Clustering via Adaptive Graph Convolution》
Why should offline stores do new retail?
MATLAB小技巧(22)矩阵分析--逐步回归
Redis - problèmes de cache
Sqlserver query code is 936 simplified Chinese GBK. Should I write 936 or GBK?
数据仓库建设之确定主题域
STM32 移植 RT-Thread 标准版的 FinSH 组件
Mysql判断计算结果,除以100
The realization of QT the flipping effect of QQ weather forecast window
Visual Studio配置Qt并通过NSIS实现项目打包
SuperMap iclient3d for webgl loading TMS tiles
Two batches of pure milk are unqualified? Michael responded that he was conducting a large-scale screening and sampling inspection of products
[cloud native | kubernetes] in depth understanding of deployment (VIII)
Substrate 源码追新导读: Pallet Alliance 并入主线,