2012-04-02 23 views
0

有沒有一種方法來格式化Select-String的輸出,以在結果之間包含換行符而不訴諸編寫自定義程序?有沒有一種方法來格式化Select-String的輸出以在結果之間包含換行符?

當前的行爲:

PS D:\StackOverflowSelectStringSpacingQuestion> Get-ChildItem . | Select-String a 

a.txt:1:a 
a.txt:2:a 
a.txt:3:a 

期望的行爲:

PS D:\StackOverflowSelectStringSpacingQuestion> Get-ChildItem . | Select-String a 

a.txt:1:a 

a.txt:2:a 

a.txt:3:a 

回答

1

有可能比這pithier方式,但它的工作原理:

Get-ChildItem . | Select-String a | Out-String -Stream | Foreach {"$_`n"} 
相關問題