伯恩·壳左右证明 [英] Bourne Shell Left Right Justify

查看:274
本文介绍了伯恩·壳左右证明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对脚本中的输出数据进行某种格式设置,而不肯定如何做左右对齐以及宽度.谁能指出我正确的方向?

I am trying to do some formatting on output data in a script and not positive how to do Left Right justify as well as width. Can anyone point me in the right direction?

推荐答案

您可以使用printf.例子

you can use printf. examples

$ printf "%15s" "col1"
$ printf "%-15s%-15s" "col1" "col2"

awk之类的工具也具有格式化功能

tools like awk also has formatting capabilities

$ echo "col1 col2" | awk '{printf "%15s%15s\n", $1,$2}'
           col1           col2

这篇关于伯恩·壳左右证明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆