roj*_*anu 10 powershell printf
当脚本进行时,如何让我的PowerShell脚本以表格格式打印信息.
在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
Run Code Online (Sandbox Code Playgroud)
要得到
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
Run Code Online (Sandbox Code Playgroud)
谢谢
Dav*_*ant 19
在PowerShell控制台中试试这个:
"{0}`t{1,-15}{2,-15}{3,-15}" -f "Locale", "Jar", "HelpSet", "Exception"
Run Code Online (Sandbox Code Playgroud)
您可以从PowerShell中轻松使用字符串格式.
该-f操作符是该String.Format函数的PowerShell快捷方式,包括.NET类型支持的所有标准和自定义格式.
| 归档时间: |
|
| 查看次数: |
18628 次 |
| 最近记录: |