我的这张桌子乱七八糟
DB Size_in_MB
foobar 11011.2
barfoo 4582.9
donkey 4220.8
shoryuken 555.9
hadouken 220.0
kong 214.8
super_mario_bros_p 211.1
列之间有不必要的空格。我想添加|
和调整列之间的间距。我尝试过sed 's/\t/|/g'
,sed 's/\t/\t|\t/g'
但没有成功
DB | Size_in_MB
foobar | 11011.2
barfoo | 4582.9
donkey | 4220.8
shoryuken | 555.9
hadouken | 220.0
kong | 214.8
super_mario_bros_p | 211.1
我想要这样的表:
DB | Size_in_MB
foobar | 11011.2
barfoo | 4582.9
donkey | 4220.8
shoryuken | 555.9
hadouken | 220.0
kong | 214.8
super_mario_bros_p | 211.1
答案1
column
尝试如下命令:
cat file | sed 's/\t/,|,/g' | column -s ',' -t
DB | Size_in_MB
foobar | 11011.2
barfoo | 4582.9
donkey | 4220.8
shoryuken | 555.9
hadouken | 220.0
kong | 214.8
super_mario_bros_p | 211.1