当前位置:网站首页>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边栏推荐
- 微服务组件Sentinel (Hystrix)详细分析
- Technology sharing | Frida's powerful ability to realize hook functions
- Socket programming
- Stm32f407 ------- IIC communication protocol
- 【CodeForces】CF1338A - Powered Addition【二进制】
- Leetcode 183 Customers who never order (2022.07.02)
- Face recognition 6-face_ recognition_ Py based on OpenCV, face detection and real-time tracking using Haar cascade and Dlib Library
- Socket编程
- Bottleneck period must see: how can testers who have worked for 3-5 years avoid detours and break through smoothly
- Learn BeanShell before you dare to say you know JMeter
猜你喜欢

easyPOI

stm32F407-------IIC通讯协议

SPI mechanism

Trial setup and use of idea GoLand development tool

Performance test | script template sorting, tool sorting and result analysis

How can retail enterprises open the second growth curve under the full link digital transformation

深度(穿透)选择器 ::v-deep/deep/及 > > >

Hard core observation 547 large neural network may be beginning to become aware?

4. 类和对象
![[camera topic] turn a drive to light up the camera](/img/d3/7aabaa5c75813abc4a43820b4c3706.png)
[camera topic] turn a drive to light up the camera
随机推荐
How to find summer technical internship in junior year? Are you looking for a large company or a small company for technical internship?
SPI mechanism
Explore the conversion between PX pixels and Pt pounds, mm and MM
Return a tree structure data
Swift开发学习
Kotlin middle process understanding and Practice (I)
Hard core observation 547 large neural network may be beginning to become aware?
Analysis, use and extension of open source API gateway apisex
Exception handling in kotlin process
转载收录6.5大侠写的部分Qt开发经验
各国Web3现状与未来
[Yu Yue education] reference materials of chemical experiment safety knowledge of University of science and technology of China
[leetcode] 797 and 1189 (basis of graph theory)
DQL basic operation
Cfdiv2 Fixed Point Guessing - (2 points for Interval answer)
leetcode961. Find the elements repeated N times in the array with length 2n
[shutter] shutter debugging (debugging fallback function | debug method of viewing variables in debugging | console information)
通达OA 首页门户工作台
Huakaiyun | virtual host: IP, subnet mask, gateway, default gateway
ByteDance data Lake integration practice based on Hudi