与此 Bash 命令等效的 PowerShell 是什么? [英] What is the PowerShell equivalent to this Bash command?

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

问题描述

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

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.

我认为 PowerShell 应该能够做同样的事情,但我不确定 grepxargs 是.

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.

那么,与以下 Bash 等效的 PowerShell 版本是什么?命令?

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

grep -l -r 'SomeSearchString' . | xargs -L1 tf edit

推荐答案

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

Using some UNIX aliases in PowerShell (like ls):

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

或更规范的 Powershell 形式:

or in a more canonical Powershell form:

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

并使用 PowerShell 别名:

and using PowerShell aliases:

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

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

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