如何讓我的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