[英]Using ack to search inside files with no extensions
I have some text "bar" contained in files FOO
and foo.cc
. 我有一些文本“bar”包含在文件
FOO
和foo.cc
。
Is there a way to tell ack-grep
to search inside files with no extension (namely FOO
)? 有没有办法告诉
ack-grep
搜索没有扩展名的文件(即FOO
)?
I've tried something like this: 我尝试过这样的事情:
ack-grep --type-set=foo=FOO bar
which returns the text in foo.cc, but not file FOO. 它返回foo.cc中的文本,但不返回文件FOO。
I've also added the --type-set to my .ackrc file, calling 我还将--type-set添加到我的.ackrc文件中,调用
ack-grep --help-types
shows that ack-grep is looking for .FOO
files. 表明ack-grep正在寻找
.FOO
文件。
My ack is of version 2.12. 我的ack是版本2.12。 Bellow command should work.
贝娄的命令应该有效。
$ ack --type-set make:is:Makefile --type=make string-pattern
So similarly, 所以类似地,
$ ack --type-set foo:is:FOO --type=foo string-pattern
You can combine ack-grep
's -a
(search everything) with -G
(only search files that match a given regex). 您可以将
ack-grep
的-a
(搜索所有内容)与-G
(仅搜索与给定正则表达式匹配的文件)组合在一起。 Something like: 就像是:
ack-grep -a -G '^[^.]+$' what-to-search-for
should do the trick. 应该做的伎俩。
Under ack2 you have to define a custom type: 在ack2下,您必须定义自定义类型:
ack-grep --WANTED --type-set WANTED:match:^[^.]+$ what-to-search-for
works for me. 适合我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.