当前位置:网站首页>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边栏推荐
- 苏世民:25条工作和生活原则
- Solution for processing overtime orders (Overtime unpaid)
- MySQL learning 03
- [Yu Yue education] Jiujiang University material analysis and testing technology reference
- stm32F407-------IIC通讯协议
- RestCloud ETL 跨库数据聚合运算
- Flink CDC mongoDB 使用及Flink sql解析monggo中复杂嵌套JSON数据实现
- The testing process that software testers should know
- [shutter] pull the navigation bar sideways (drawer component | pageview component)
- Storage basic operation
猜你喜欢

The testing process that software testers should know

Processing of tree structure data

通达OA v12流程中心
![[shutter] shutter debugging (debugging fallback function | debug method of viewing variables in debugging | console information)](/img/66/0fda43da0d36fc0c9277ca86ece252.jpg)
[shutter] shutter debugging (debugging fallback function | debug method of viewing variables in debugging | console information)
![[leetcode] 797 and 1189 (basis of graph theory)](/img/2a/9c0a904151a17c2d23dea9ad04dbfe.jpg)
[leetcode] 797 and 1189 (basis of graph theory)

全链路数字化转型下,零售企业如何打开第二增长曲线

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

In the face of difficult SQL requirements, HQL is not afraid
![[shutter] top navigation bar implementation (scaffold | defaulttabcontroller | tabbar | tab | tabbarview)](/img/f1/b17631639cb4f0f58007b86476bcc2.gif)
[shutter] top navigation bar implementation (scaffold | defaulttabcontroller | tabbar | tab | tabbarview)

Detailed introduction to the deployment and usage of the Nacos registry
随机推荐
Comment communiquer avec Huawei Cloud IOT via le Protocole mqtt
Bottleneck period must see: how can testers who have worked for 3-5 years avoid detours and break through smoothly
《上市风云》荐书——唯勇气最可贵
Leetcode 183 Customers who never order (2022.07.02)
[leetcode] 797 and 1189 (basis of graph theory)
Job object of collaboration in kotlin
What are MySQL locks and classifications
His experience in choosing a startup company or a big Internet company may give you some inspiration
机器学习流程与方法
Socket编程
When the epidemic comes, how to manage the team as a leader| Community essay solicitation
Detailed introduction to the usage of Nacos configuration center
Explore the conversion between PX pixels and Pt pounds, mm and MM
Method of removing webpage scroll bar and inner and outer margins
Analysis, use and extension of open source API gateway apisex
Comment le chef de file gère - t - il l'équipe en cas d'épidémie? Contributions communautaires
Swift development learning
[shutter] bottom navigation bar implementation (bottomnavigationbar bottom navigation bar | bottomnavigationbaritem navigation bar entry | pageview)
String replace space
[Yu Yue education] reference materials of chemical experiment safety knowledge of University of science and technology of China