什么是PowerShell等同于这个Bash命令? [英] What is the PowerShell equivalent to this Bash command?

查看:168
本文介绍了什么是PowerShell等同于这个Bash命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试创建一个 CLI 命令,让 TFS 检查所有文件中包含特定字符串的文件。我主要使用 Cygwin ,但 tf 命令无法在Cygwin环境中运行时解决路径问题。



PowerShell应该可以做同样的事情,但我不确定相同的东西命令 grep xargs 都是。所以,什么是等效的PowerShell版本以下 Bash 命令?

  grep -l -r'SomeSearchString'。 | xargs -L1 tf编辑


解决方案

在PowerShell中使用一些UNIX别名(如ls):

  ls -r |选择字符串'SomeSearchString'| Foreach {tf编辑$ _。路径} 

或者更典型的Powershell窗体:

  Get-ChildItem -Recurse |选择字符串'SomeSearchString'| 
Foreach {tf编辑$ _。路径}

并使用PowerShell别名:

  gci -r | sls'SomeSearchString'| %{tf edit $ _。Path} 


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

解决方案

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}

这篇关于什么是PowerShell等同于这个Bash命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆