如何让我的PowerShell脚本在脚本进行时以表格格式打印信息。在PowerShell控制台如何在PowerShell中创建printf效果
在bash,我会做这个通过
printf "%s\t%-15.15s" "Locale" "Jar"
if($verbose);then
printf "%-15.15s %-15.15s" "HelpSet" "Exception"
fi
printf "\t%s\n" "Status"
...
printf "%s\t%-15.15s" $locale $helpFileName
if($verbose); then
printf "%-15.15s %-15.15s" "$helpSetName" ${exclusion[$helpFileName]}
fi
status="OK"
...
if ($fixed); then
status="CORRECTED"
fi
printf "\t%s\n" $status
得到
Locale Jar HelpSet Exception Status
de help_D150 help_D150 CORRECTED
es help_D150 help_D150 OK
fr help_D150 help_D150 OK
it Locale folder not found
nl help_D150 help_D150 CORRECTED
感谢
通过这种方法,两个条件列被打印在一个新行上而不是在同一行上 – rojanu 2012-03-28 10:43:44
使用单个格式字符串,合并所有列,并且对不希望打印的参数使用$ null或空字符串。 – 2012-03-28 10:48:52