当前位置:网站首页>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
边栏推荐
- How do it students find short-term internships? Which is better, short-term internship or long-term internship?
- 微信小程序开发工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理问题
- How to find summer technical internship in junior year? Are you looking for a large company or a small company for technical internship?
- [camera topic] how to save OTP data in user-defined nodes
- Job object of collaboration in kotlin
- Wechat applet development tool post net:: err_ PROXY_ CONNECTION_ Failed agent problem
- Comment communiquer avec Huawei Cloud IOT via le Protocole mqtt
- 返回一个树形结构数据
- Reprint some Qt development experience written by great Xia 6.5
- How to refresh the opening amount of Oracle ERP
猜你喜欢
8 free, HD, copyright free video material download websites are recommended
easyExcel
微服务组件Sentinel (Hystrix)详细分析
What are the differences between software testers with a monthly salary of 7K and 25K? Leaders look up to you when they master it
[leetcode] 797 and 1189 (basis of graph theory)
Trial setup and use of idea GoLand development tool
Deep learning notes (constantly updating...)
How do it students find short-term internships? Which is better, short-term internship or long-term internship?
Hard core observation 547 large neural network may be beginning to become aware?
Redis:Redis的简单使用
随机推荐
返回一个树形结构数据
Answers to ten questions about automated testing software testers must see
详细些介绍如何通过MQTT协议和华为云物联网进行通信
机器学习笔记(持续更新中。。。)
微信小程序开发工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理问题
The Sandbox阐释对元宇宙平台的愿景
微信小程序開發工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理問題
Cfdiv2 fixed point guessing- (interval answer two points)
Basic operation of view
iptables 4层转发
Depth (penetration) selector:: v-deep/deep/ and > > >
Bottleneck period must see: how can testers who have worked for 3-5 years avoid detours and break through smoothly
Leetcode(540)——有序数组中的单一元素
require. context
浏览器是如何对页面进行渲染的呢?
[Yu Yue education] China Ocean University job search OMG reference
elastic stack
Huakaiyun (Zhiyin) | virtual host: what is a virtual host
stm32F407-------DMA
[shutter] shutter debugging (debugging control related functions | breakpoint management | code operation control)