当前位置:网站首页>awk从入门到入土(3)awk内置函数printf和print实现格式化打印
awk从入门到入土(3)awk内置函数printf和print实现格式化打印
2022-07-03 02:13:00 【奇妙之二进制】
awk中print与printf的主要差别显示在以下两点:
- print在显示多个结果的时候以逗号分隔,结果将这几部分的内容自动使用输出分隔符(字段输出分割符默认是空格,记录输出分割符默认是换行符)进行分隔,且不需要添加换行符\n;如果不使用,间隔,则打印时会连在一起,即使使用了空格:
[email protected]:~$ awk -F: 'BEGIN{k=1} {print $1,$2}' /etc/passwd
root x
daemon x
bin x
sys x
[email protected]:~$ awk -F: 'BEGIN{k=1} {print $1 $2}' /etc/passwd
rootx
daemonx
binx
sysx
syncx
gamesx
- printf可以更加灵活的控制某一个字段的输出格式,通过使用诸如%-12s,%3.1f等格式化方法。printf更加接近使用C语言的同学的习惯。
$ awk -F: 'BEGIN{k=1} {printf "%s,%s边栏推荐
- leetcode961. Find the elements repeated N times in the array with length 2n
- 502 (bad gateway) causes and Solutions
- In 2022, 95% of the three most common misunderstandings in software testing were recruited. Are you that 5%?
- [Yu Yue education] reference materials of love psychology of China University of mining and technology
- Trial setup and use of idea GoLand development tool
- Storage basic operation
- 转载收录6.5大侠写的部分Qt开发经验
- stm32F407-------ADC
- Unrecognized SSL message, plaintext connection?
- 【Camera专题】手把手撸一份驱动 到 点亮Camera
猜你喜欢

Machine learning notes (constantly updating...)
![[shutter] bottom navigation bar implementation (bottomnavigationbar bottom navigation bar | bottomnavigationbaritem navigation bar entry | pageview)](/img/41/2413af283e8f1db5d20ea845527175.gif)
[shutter] bottom navigation bar implementation (bottomnavigationbar bottom navigation bar | bottomnavigationbaritem navigation bar entry | pageview)

Use go language to realize try{}catch{}finally

Visual yolov5 format data set (labelme JSON file)

微服务组件Sentinel (Hystrix)详细分析

Anna: Beibei, can you draw?

Detailed introduction to the usage of Nacos configuration center

PyTorch 卷积网络正则化 DropBlock

stm32F407-------DMA

How can retail enterprises open the second growth curve under the full link digital transformation
随机推荐
Depth (penetration) selector:: v-deep/deep/ and > > >
通达OA v12流程中心
Missing library while loading shared libraries: libisl so. 15: cannot open shared object file: No such file
Answers to ten questions about automated testing software testers must see
[shutter] pull the navigation bar sideways (drawer component | pageview component)
机器学习流程与方法
我的创作纪念日
[camera topic] turn a drive to light up the camera
Qt之QComboBox添加QCheckBox(下拉列表框插入复选框,含源码+注释)
Stm32f407 ------- IIC communication protocol
Kotlin middle process understanding and Practice (I)
【Camera专题】OTP数据如何保存在自定义节点中
In the face of difficult SQL requirements, HQL is not afraid
Deep learning notes (constantly updating...)
Machine learning notes (constantly updating...)
《上市风云》荐书——唯勇气最可贵
Cancellation of collaboration in kotlin, side effects of cancellation and overtime tasks
Use go language to realize try{}catch{}finally
缺少库while loading shared libraries: libisl.so.15: cannot open shared object file: No such file
4. 类和对象