在bash中右对齐/编号
发布时间:2020-12-15 19:24:54 所属栏目:安全 来源:网络整理
导读:在bash中打印输出时,最好的方法是填充数字,以使数字在屏幕上对齐。所以这: 00364.txt with 28 words in 0m0.927s00366.txt with 105 words in 0m2.422s00367.txt with 168 words in 0m3.292s00368.txt with 1515 words in 0m27.238 应该打印如下: 00364.
在bash中打印输出时,最好的方法是填充数字,以使数字在屏幕上对齐。所以这:
00364.txt with 28 words in 0m0.927s 00366.txt with 105 words in 0m2.422s 00367.txt with 168 words in 0m3.292s 00368.txt with 1515 words in 0m27.238 应该打印如下: 00364.txt with 28 words in 0m0.927s 00366.txt with 105 words in 0m2.422s 00367.txt with 168 words in 0m3.292s 00368.txt with 1515 words in 0m27.238 我从一个for循环中逐行打印出来。我会知道一个文件中的单词数量的上限(现在不是这样)。
对于bash,请使用带对齐标记的printf命令。
例如: printf '%7s' 'hello' 打印: hello (想象一下这里有2个空间) 现在,您可以自行决定是否出现问题。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |