当前位置:网站首页>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边栏推荐
- MySQL学习03
- [Flutter] dart: class;abstract class;factory;类、抽象类、工厂构造函数
- [fluent] fluent debugging (debug debugging window | viewing mobile phone log information | setting normal breakpoints | setting expression breakpoints)
- Missing library while loading shared libraries: libisl so. 15: cannot open shared object file: No such file
- 机器学习流程与方法
- Anna: Beibei, can you draw?
- [Yu Yue education] reference materials of chemical experiment safety knowledge of University of science and technology of China
- DML Foundation
- [camera topic] complete analysis of camera dtsi
- Servlet中数据传到JSP页面使用el表达式${}无法显示问题
猜你喜欢

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

RestCloud ETL 跨库数据聚合运算

Return a tree structure data
![[camera topic] how to save OTP data in user-defined nodes](/img/3e/b76c4d6ef9ab5f5b4326a3a8aa1c4f.png)
[camera topic] how to save OTP data in user-defined nodes

How to deal with cache hot key in redis

The testing process that software testers should know

Visual yolov5 format data set (labelme JSON file)

Technology sharing | Frida's powerful ability to realize hook functions

通达OA 首页门户工作台

技术大佬准备就绪,话题C位由你决定
随机推荐
The Sandbox阐释对元宇宙平台的愿景
Storage basic operation
单词单词单词
[Flutter] dart: class; abstract class; factory; Class, abstract class, factory constructor
Method of removing webpage scroll bar and inner and outer margins
Solution for processing overtime orders (Overtime unpaid)
Servlet中数据传到JSP页面使用el表达式${}无法显示问题
COM and cn
微信小程序开发工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理问题
File class (add / delete)
iptables 4层转发
Prohibited package name
Su Shimin: 25 principles of work and life
深度学习笔记(持续更新中。。。)
可視化yolov5格式數據集(labelme json文件)
Hard core observation 547 large neural network may be beginning to become aware?
Huakaiyun | virtual host: IP, subnet mask, gateway, default gateway
Coroutinecontext in kotlin
Iptables layer 4 forwarding
leetcode961. Find the elements repeated N times in the array with length 2n