What is the PowerShell equivalent to this Bash command?

前端 未结 2 1057
隐瞒了意图╮
隐瞒了意图╮ 2020-12-31 17:01

I\'m trying to create a CLI command to have TFS check out all files that have a particular string in them. I primarily use Cygwin, but the tf command has troubl

相关标签:
2条回答
  • 2020-12-31 17:46

    Using some UNIX aliases in PowerShell (like ls):

    ls -r | select-string 'SomeSearchString' | Foreach {tf edit $_.Path}
    

    or in a more canonical Powershell form:

    Get-ChildItem -Recurse | Select-String 'SomeSearchString' | 
        Foreach {tf edit $_.Path}
    

    and using PowerShell aliases:

    gci -r | sls 'SomeSearchString' | %{tf edit $_.Path}
    
    0 讨论(0)
  • 2020-12-31 17:49

    I find it easier to grok using a variable, e.g.,

    PS> $files = Get-ChildItem -Recurse | 
           Select-String 'SomeSearchString' | 
           %{$_.path}  | 
           Select -Unique
    PS> tf edit $files
    
    0 讨论(0)
提交回复
热议问题