Listing full address path with Windows PowerShell
I have a small script that searches through all files in a directory using something like this;
Get-Ch开发者_Python百科ildItem $location -recurse | select-string -pattern $pattern | select-object Path, FileName, LineNumber > C:\test.txt
The problem I have is that the Path gets enshortened, like this;
C:\program files\new folder\new f...
How can I get it to display the full path?
Just so it's clear why you saw the truncating behavior, the default formatter picked is Format-Table
which divies up the current host width into three equally sized columns and if the data is wider than that it gets truncated. Another way of doing this:
gci $location -r | select-string $pattern |
Format-Table Path, FileName, LineNumber -Auto |
Out-File C:\test.txt -width 512
Export-Csv
made it possible, thanks to BartekB and denty on freenode's #powershell
精彩评论