svn - 如何使用findstr,在gvim中排除svn目录

标签 svn vim cmd findstr

我想找出一个目录及其所有子目录中所有包含关键字的文件,并且有一些.svn目录,我应该忽略这些目录。

在 Linux 系统中,我可以很容易地做到这一点:

  grep -r keyword ./ --exclude-dir ".svn"

但是当我转向 windows 时,findstr 是 windows 中 grep 的替代品,我尝试这样做:

  findstr /s keyword ./*

结果会返回.svn目录,这不是我想要的。

我读了TN Findstr, on microsoft website

  /v   : Prints only lines that do not contain a match.

但是当我像下面这样尝试时,它仍然不起作用。

 findstr /s keyword /v ".svn" ./*

我认为我对 findstr 的使用可能存在一些问题。任何帮助都会很棒,提前致谢。

        ***************************** update1 *****************************

事实上,我正在尝试在 GVim 中使用 grep,它会调用 'findstr`。

最佳答案

据我所知,您不能排除 findstr 中的特定(子)文件夹。不过,在 PowerShell 中,您可以这样做:

$root = '.'
$keyword = 'keyword'

Get-ChildItem $root -Recurse -Force | ? {
  -not $_.PSIsContainer -and $_.FullName -notlike "*\.svn*"
} | Select-String $keyword -AllMatches

或者您可以利用 .svn 子文件夹被隐藏的事实并执行此操作:

$root = '.'
$keyword = "keyword"

Get-ChildItem $root -Recurse | ? { -not $_.PSIsContainer } |
    Select-String $keyword -AllMatches

但是,如果您要搜索的某些文件设置了 hidden 属性,这将不起作用。

关于svn - 如何使用findstr,在gvim中排除svn目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17917998/

相关文章:

Vim 高亮相似包括特殊字符

linux - vim ctags,两个相同的条目,不会直接跳转到定义

python - cygwin 运行命令而不是 cmd python

powershell - 如何使用 cmd/Powershell 或其他方式打开电源选项 > 系统设置

svn - 在SVN中的同行评审之前防止提交

windows - TortoiseSVN 和 commit-access-control.cfg

svn - 免费在线存储库 (CVS)

Vim命令在普通模式下插入空行

powershell - 在Windows Server 2012实例上通过cmd完成时,通过PowerShell使用 'net use'表现出不同的行为

git - svn 到 git 的转换