Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the PowerShell equivalent to this Bash command?

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 trouble resolving the path when run within the Cygwin environment.

I figure PowerShell should be able to do the same thing, but I'm not sure what the equivalent commands to grep and xargs are.

So, what would be the equivalent PowerShell version to the following Bash command?

grep -l -r 'SomeSearchString' . | xargs -L1 tf edit
like image 857
Herms Avatar asked Jan 20 '10 16:01

Herms


1 Answers

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}
like image 57
Keith Hill Avatar answered Sep 20 '22 14:09

Keith Hill