开发者

Listing full address path with Windows PowerShell

开发者 https://www.devze.com 2023-01-22 04:22 出处:网络
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 Pat

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号