在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个空间)
现在,您可以自行决定是否出现问题。