当前位置:网站首页>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
边栏推荐
- Stm32f407 ------- IIC communication protocol
- 返回一个树形结构数据
- [shutter] shutter debugging (debugging control related functions | breakpoint management | code operation control)
- 转载收录6.5大侠写的部分Qt开发经验
- Solution for processing overtime orders (Overtime unpaid)
- Huakaiyun (Zhiyin) | virtual host: what is a virtual host
- Swift开发学习
- [Flutter] dart: class;abstract class;factory;类、抽象类、工厂构造函数
- The testing process that software testers should know
- Huakaiyun | virtual host: IP, subnet mask, gateway, default gateway
猜你喜欢
Distributed transaction solution
easyPOI
[shutter] hero animation (hero realizes radial animation | hero component createrecttween setting)
LabVIEW安装第三方VISA软件后NI VISA失效
技术大佬准备就绪,话题C位由你决定
stm32F407-------ADC
stm32F407-------DMA
The technology boss is ready, and the topic of position C is up to you
[fluent] hero animation (hero animation use process | create hero animation core components | create source page | create destination page | page Jump)
Y54. Chapter III kubernetes from introduction to mastery -- ingress (27)
随机推荐
udp接收队列以及多次初始化的测试
Cfdiv2 fixed point guessing- (interval answer two points)
Missing library while loading shared libraries: libisl so. 15: cannot open shared object file: No such file
详细些介绍如何通过MQTT协议和华为云物联网进行通信
Visual yolov5 format data set (labelme JSON file)
stm32F407-------DMA
Unrecognized SSL message, plaintext connection?
[Flutter] dart: class;abstract class;factory;类、抽象类、工厂构造函数
leetcode961. Find the elements repeated N times in the array with length 2n
Return a tree structure data
Prohibited package name
Trial setup and use of idea GoLand development tool
Coroutinecontext in kotlin
Button button adaptive size of wechat applet
Servlet中数据传到JSP页面使用el表达式${}无法显示问题
疫情當頭,作為Leader如何進行團隊的管理?| 社區征文
[Yu Yue education] reference materials of chemical experiment safety knowledge of University of science and technology of China
Learn BeanShell before you dare to say you know JMeter
【Camera专题】OTP数据如何保存在自定义节点中
[Yu Yue education] Jiujiang University material analysis and testing technology reference