当前位置:网站首页>awk从入门到入土(1)awk初次会面
awk从入门到入土(1)awk初次会面
2022-07-03 02:13:00 【奇妙之二进制】
先给大家一个awk的简单实例,带大家了解awk命令的基本结构。
1、首次体验
先创建一个名为 marks.txt 的文件。其中包括序列号、学生名字、课程名称与所得分数。
1) Amit Physics 80
2) Rahul Maths 90
3) Shyam Biology 87
4) Kedar English 85
5) Hari History 89
接下来,我们将使用 AWK 脚本来显示输出文件中的内容,同时输出表头信息。
[jerry]$ awk 'BEGIN{printf "Sr No\tName\tSub\tMarks\n"} {print} END{printf "----------------------------\n"}' marks.txt
执行上面的代码后,将会输出如下的结果:
Sr No Name Sub Marks
1) Amit Physics 80
2) Rahul Maths 90
3) Shyam Biology 87
4) Kedar English 85
5) Hari History 89
----------------------------
输出多了个表头和分割线,除此之外看起来和源文件内容没什么差别。但这条语句描述了awk语法的基本结构,下面介绍。
awk 'BEGIN{printf "Sr No\tName\tSub\tMarks\n"} {print} END{printf "---------------
边栏推荐
- Trial setup and use of idea GoLand development tool
- [leetcode] 797 and 1189 (basis of graph theory)
- Pytorch convolution network regularization dropblock
- 详细些介绍如何通过MQTT协议和华为云物联网进行通信
- When the epidemic comes, how to manage the team as a leader| Community essay solicitation
- Startup mode and scope builder of collaboration in kotlin
- How to refresh the opening amount of Oracle ERP
- Machine learning notes (constantly updating...)
- Job object of collaboration in kotlin
- The Sandbox阐释对元宇宙平台的愿景
猜你喜欢
Stm32f407 ------- IIC communication protocol
[camera topic] turn a drive to light up the camera
Wechat applet development tool post net:: err_ PROXY_ CONNECTION_ Failed agent problem
Wechat applet Development Tool Post net:: Err Proxy Connexion Problèmes d'agent défectueux
Pytorch convolution network regularization dropblock
Visualisation de l'ensemble de données au format yolov5 (fichier labelme json)
Trial setup and use of idea GoLand development tool
[shutter] shutter debugging (debugging fallback function | debug method of viewing variables in debugging | console information)
How to deal with cache hot key in redis
Depth (penetration) selector:: v-deep/deep/ and > > >
随机推荐
5.文件操作
stm32F407-------ADC
机器学习流程与方法
How to refresh the opening amount of Oracle ERP
详细些介绍如何通过MQTT协议和华为云物联网进行通信
Detailed introduction to the deployment and usage of the Nacos registry
y54.第三章 Kubernetes从入门到精通 -- ingress(二七)
Rockchip3399 start auto load driver
Analysis, use and extension of open source API gateway apisex
Unrecognized SSL message, plaintext connection?
4. 类和对象
Unrecognized SSL message, plaintext connection?
微信小程序开发工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理问题
DML Foundation
How do browsers render pages?
[fluent] fluent debugging (debug debugging window | viewing mobile phone log information | setting normal breakpoints | setting expression breakpoints)
Explore the conversion between PX pixels and Pt pounds, mm and MM
[camera topic] complete analysis of camera dtsi
Trial setup and use of idea GoLand development tool
The technology boss is ready, and the topic of position C is up to you