按Tab键均匀地用awk打印领域 [英] Tabbing the printed fields evenly using awk
本文介绍了按Tab键均匀地用awk打印领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要用awk帮助。谢谢
我有它包含以下内容的文件
的text.txt
饥饿游戏:苏珊·柯林斯:1:2:3
武器X:斯坦·李:3:4:5
在code,我用打印的行
的awk -F'[:]''{打印$ 1,$ 2,$$ 3,$ 4,$ 5}'BookDB.txt
我希望为出把变成这个样子
饥饿游戏苏珊·柯林斯1 2 3
武器x斯坦·李3 4 5
解决方案
您可以通过管道AWK输出到列
是这样的:
的awk -F:-v OFS =':''{打印$ 1,$ 2,$ 3,$ 4 $ 5}'BookDB.txt |列-s':'-t
饥饿游戏苏珊·柯林斯1 2 3
武器x斯坦·李3 4 5
i need help using awk. Thanks
i have a file it contains the following
text.txt
The Hunger Games:Suzanne Collins:1:2:3
Weapon X:Stan Lee:3:4:5
the code that i was using to print the lines
awk -F '[:]' '{print $1, $2 ,"$"$3, $4 , $5 }' BookDB.txt
i wish for the out put to become like this
The Hunger Games Suzanne Collins 1 2 3
Weapon X Stan Lee 3 4 5
解决方案
You can pipe awk output to column
like this:
awk -F ':' -v OFS=':' '{print $1, $2 , $3, $4 , $5}' BookDB.txt | column -s ':' -t
The Hunger Games Suzanne Collins 1 2 3
Weapon X Stan Lee 3 4 5
这篇关于按Tab键均匀地用awk打印领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文