可以用 4DOS 的 @format 变量函数
4DOS Help Topic: @FORMAT
@FORMATx],string]: Reformats a string, truncating it or padding
it with spaces as necessary. If you use the minus , the string is
left-justified; otherwise, it is right-justified. The x value is the
minimum number of characters in the result. The y value is the maximum
number of characters in the result. You can combine the options as
necessary. For example:
"%@format" returns " JPSoftware"
"%@format" returns "JPS"
@FORMAT will add leading or trailing spaces if necessary to pad the result
to the minimum width specified by x. If a leading zero is used before x,
the padding will be with 0's instead, for example:
"%@format" returns " 5"
"%@format" returns "0005"
"%@format" returns "5000"
See also the @COMMA function, which can make numeric values easier to read
by inserting thousands separators.
要每列左对齐的话,也就是说前一列的长度都要相同,少于所需长度的要填充空格(也可以是0),以你的例子为例,假定第一列的最大字串长度为6(列之间的空格不计,是随便你预先输入的,当然,也可以包括到函数中去)。
echo %@format test
得到的结果就是
123 test