当前位置:网站首页>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边栏推荐
- 浏览器是如何对页面进行渲染的呢?
- [shutter] bottom navigation bar implementation (bottomnavigationbar bottom navigation bar | bottomnavigationbaritem navigation bar entry | pageview)
- File class (add / delete)
- 深度(穿透)选择器 ::v-deep/deep/及 > > >
- DDL basic operation
- Coroutinecontext in kotlin
- stm32F407-------IIC通讯协议
- Ni visa fails after LabVIEW installs the third-party visa software
- 通达OA 首页门户工作台
- stm32F407-------ADC
猜你喜欢

Job object of collaboration in kotlin

Servlet中数据传到JSP页面使用el表达式${}无法显示问题

MySQL learning 03

Analysis, use and extension of open source API gateway apisex

y54.第三章 Kubernetes从入门到精通 -- ingress(二七)

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

Return a tree structure data

stm32F407-------ADC
![[shutter] hero animation (hero realizes radial animation | hero component createrecttween setting)](/img/e7/915404743d6639ac359bb4e7f7fbb7.jpg)
[shutter] hero animation (hero realizes radial animation | hero component createrecttween setting)

How can retail enterprises open the second growth curve under the full link digital transformation
随机推荐
Trial setup and use of idea GoLand development tool
[leetcode] 797 and 1189 (basis of graph theory)
Flink CDC mongoDB 使用及Flink sql解析monggo中复杂嵌套JSON数据实现
Performance test | script template sorting, tool sorting and result analysis
Kotlin middle process understanding and Practice (II)
通达OA v12流程中心
Ni visa fails after LabVIEW installs the third-party visa software
Rockchip3399 start auto load driver
微信小程序開發工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理問題
Detailed introduction to the deployment and usage of the Nacos registry
A 30-year-old software tester, who has been unemployed for 4 months, is confused and doesn't know what to do?
How to refresh the opening amount of Oracle ERP
Modify table structure
Leetcode (540) -- a single element in an ordered array
SPI mechanism
【Camera专题】手把手撸一份驱动 到 点亮Camera
[camera topic] complete analysis of camera dtsi
各国Web3现状与未来
《上市风云》荐书——唯勇气最可贵
2022 spring "golden three silver four" job hopping prerequisites: Software Test interview questions (with answers)