gpt4 book ai didi

ubuntu - ack(ack-grep) 忽略嵌套目录

转载 作者:行者123 更新时间:2023-12-04 18:30:31 28 4
gpt4 key购买 nike

我有 ubuntu 14.04。并使用 ack-grep 2.12 在目录内递归搜索文件中的文本

我想设置 ack-grep 选项
特定于目录 ~/workspace/project/
这样当我在路径 ~/workspace/project 并执行 ack 'mypattern'
它在所有子目录和孙子目录中递归搜索,并在所有文件中递归搜索。并打印结果。此外,我有一些子目录和一些大子目录来忽略其中的所有文件。

目前我有一个文件 .ackrc 作为 ~/workspace/project/.ackrc

我写的地方

  --ignore-directory=is:node_modules/
--ignore-directory=is:public/bower_compoenents/

现在当我搜索 ack-grep 'hello'
它还搜索我指示从 .ackrc 忽略的所有目录

即使在 .ackrc 中使用此模式,它也会再次搜索被忽略的目录。 (PS:这在mac os x中完美运行[编辑:可能使用旧版本的ack])
  --ignore-dir=node_modules/
--ignore-dir=public/bower_compoenents/

到目前为止,这些都没有奏效
--ignore-dir=public/bower_components --ignore-dir=is:public/bower_components
我做错什么了吗?

编辑:寻找解决方案以忽略嵌套目录中的搜索。 (我不想在命令行上执行 ack-grep 时提供任何特殊选项)

最佳答案

引自 ack 2.12 manual :

--[no]ignore-dir=DIRNAME, --[no]ignore-directory=DIRNAME

Ignore directory (as CVS, .svn, etc are ignored). May be used multiple times to ignore multiple directories. For example, mason users may wish to include --ignore-dir=data. The --noignore-dir option allows users to search directories which would normally be ignored (perhaps to research the contents of .svn/props directories).

The DIRNAME must always be a simple directory name. Nested directories like foo/bar are NOT supported. You would need to specify --ignore-dir=foo and then no files from any foo directory are taken into account by ack unless given explicitly on the command line.


所以看起来你需要删除斜杠和嵌套目录。
你确定这适用于你的另一台机器吗?那台机器上有什么版本的ack?

关于ubuntu - ack(ack-grep) 忽略嵌套目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27344546/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com