当前位置:网站首页>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边栏推荐
- Machine learning notes (constantly updating...)
- Technology sharing | Frida's powerful ability to realize hook functions
- CFdiv2-Fixed Point Guessing-(区间答案二分)
- [camera topic] complete analysis of camera dtsi
- Modify table structure
- 詳細些介紹如何通過MQTT協議和華為雲物聯網進行通信
- [shutter] shutter debugging (debugging control related functions | breakpoint management | code operation control)
- Leetcode 183 Customers who never order (2022.07.02)
- [fluent] hero animation (hero animation use process | create hero animation core components | create source page | create destination page | page Jump)
- Rockchip3399 start auto load driver
猜你喜欢

easyExcel

Coroutinecontext in kotlin

Anna: Beibei, can you draw?

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

Ni visa fails after LabVIEW installs the third-party visa software

Flink CDC mongoDB 使用及Flink sql解析monggo中复杂嵌套JSON数据实现

使用Go语言实现try{}catch{}finally

What are the differences between software testers with a monthly salary of 7K and 25K? Leaders look up to you when they master it

创建+注册 子应用_定义路由,全局路由与子路由

stm32F407-------ADC
随机推荐
SPI mechanism
【CodeForces】CF1338A - Powered Addition【二进制】
2022 spring "golden three silver four" job hopping prerequisites: Software Test interview questions (with answers)
What are the differences between software testers with a monthly salary of 7K and 25K? Leaders look up to you when they master it
创建+注册 子应用_定义路由,全局路由与子路由
Groovy, "try with resources" construction alternative
[fluent] fluent debugging (debug debugging window | viewing mobile phone log information | setting normal breakpoints | setting expression breakpoints)
How do it students find short-term internships? Which is better, short-term internship or long-term internship?
stm32F407-------DMA
The testing process that software testers should know
In 2022, 95% of the three most common misunderstandings in software testing were recruited. Are you that 5%?
[Flutter] dart: class; abstract class; factory; Class, abstract class, factory constructor
[Yu Yue education] reference materials of love psychology of China University of mining and technology
CFdiv2-Fixed Point Guessing-(區間答案二分)
Query product cases - page rendering data
MySQL learning 03
Wechat applet development tool post net:: err_ PROXY_ CONNECTION_ Failed agent problem
Qt之QComboBox添加QCheckBox(下拉列表框插入复选框,含源码+注释)
Anna: Beibei, can you draw?
What are the key points often asked in the redis interview