ack

ack: Excluding only one directory but keeping all others with the same name

…衆ロ難τιáo~ 提交于 2019-12-03 09:18:35
My folder structure looks like this: /app /app/data ... /app/secondary /app/secondary/data I want to recursively search /app , including /app/data . I do not want to search /app/secondary/data however. This what I have so far: ack --ignore-dir=data searchtext ack --ignore-dir=secondary/data searchtext The first command is ignoring both directories and the second one is ignoring neither of them. From within the app folder, what should my ack command look like? rkulla This answer is for versions of Ack prior to 2, see This answer for versions of Ack >=2 . The first one is ignoring both because

Search for files & file names using silver searcher

倾然丶 夕夏残阳落幕 提交于 2019-12-03 05:42:00
问题 Using Silver Searcher, how can I search for: (non-binary) files with a word or pattern AND all filenames , with a word or pattern including filenames of binary files. Other preferences: would like to have case insensitive search and search through dotfiles. Tried to alias using this without much luck: alias search="ag -g $1 --smart-case --hidden && ag --smart-case --hidden $1" 回答1: According to the man page of ag -G --file-search-regex PATTERN Only search files whose names match PATTERN. You

Ignoring a directory using ack's .ackrc

两盒软妹~` 提交于 2019-12-03 05:23:52
问题 I'm not sure what it's for, but the code I'm working on has a bunch of folders called "save.d," it looks like they're used for some sort of version control (we also have .svn folders). How can I update my .ackrc file to ignore those directories by default? My .ackrc is currently --type-set=inc=.inc --ignore-dir=pear --type-set=tpl=.tpl Our folder structure can look like: program/parsers/save.d program/modules/save.d 回答1: Adding another line --ignore-dir=save.d did the trick 来源: https:/

Can ack find files based on filename only?

人盡茶涼 提交于 2019-12-03 03:39:56
问题 Using ack (sometimes packaged as ack-grep) I know that I can find paths that contain a specific string by doing: ack -g somestring But what if I only want files which have "somestring" in their filenames ? 回答1: You can use find utility. Something like this: find /path/to/look/in -name '*somestring*' -print On some systems, if you omit the path, current directory is used. On other systems you can't omit it, just use . for current directory instead. Also, read man find for many other options.

How to use named regex groups in ack output?

百般思念 提交于 2019-12-03 03:27:21
Suppose I have a foo.txt file with the following content: [2010-11-13 12:00:02,656] [2010-11-13 12:00:02,701] [2010-11-13 12:00:02,902] When I ack for the date portion with the following, it works: ack "(?P<foo>\d{4}-\d{2}-\d{2})" foo.txt --output "\$1" 2010-11-13 2010-11-13 2010-11-13 But when I try to use --output with the named group "foo", I cannot get it to work: ack "(?P<foo>\d{4}-\d{2}-\d{2})" foo.txt --output "(?P=foo)" (?=foo) (?=foo) (?=foo) Any help is greatly appreciate it. Thanks so much. ack "(?P<foo>\d{4}-\d{2}-\d{2})" foo.txt --output "\$+{foo}" (?P=foo) only works inside the

Escaping a parenthesis in grep/ack

陌路散爱 提交于 2019-12-03 02:19:31
I want to look for the string "methodname(", but I am unable to escape the "(". How can I get grep methodname( * or ack-grep methodname( * to work? There's two things interpreting the ( : the shell, and ack-grep . You can use '' , "" , or \ to escape the ( from the shell, e.g. grep 'methodname(' * grep "methodname(" * grep methodname\( * grep uses a basic regular expression language by default, so ( isn't special. (It would be if you used egrep or grep -E or grep -P .) On the other hand, ack-grep takes Perl regular expressions as input, in which ( is also special, so you'll have to escape that

Search for files & file names using silver searcher

我怕爱的太早我们不能终老 提交于 2019-12-02 20:28:19
Using Silver Searcher, how can I search for: (non-binary) files with a word or pattern AND all filenames , with a word or pattern including filenames of binary files. Other preferences: would like to have case insensitive search and search through dotfiles. Tried to alias using this without much luck: alias search="ag -g $1 --smart-case --hidden && ag --smart-case --hidden $1" vincentleest According to the man page of ag -G --file-search-regex PATTERN Only search files whose names match PATTERN. You can use the -G option to perform searches on files matching a pattern. So, to answer your

ack: Exclude specific directories from search via regex

二次信任 提交于 2019-12-02 20:22:38
How do I ignore specific directories via RegEx with ack ? I can use the --ignore-dir option, but this does not let me specify a RegEx. I want to be able to ignore any directory, which has the words test or tests or more complicated patterns in its name. I also tried a negative lookbehind via ack -G '(?<!test)' pattern but this does not work. It does not exclude the test directories. Use the undocumented option "--invert-file-match" (ack version on my system: 1.96): $ ack pattern -G 'test|tests' --invert-file-match Well, it is sort of documented: $ ack --help|grep invert -v, --invert-match

Ignoring a directory using ack's .ackrc

点点圈 提交于 2019-12-02 18:40:37
I'm not sure what it's for, but the code I'm working on has a bunch of folders called "save.d," it looks like they're used for some sort of version control (we also have .svn folders). How can I update my .ackrc file to ignore those directories by default? My .ackrc is currently --type-set=inc=.inc --ignore-dir=pear --type-set=tpl=.tpl Our folder structure can look like: program/parsers/save.d program/modules/save.d Adding another line --ignore-dir=save.d did the trick 来源: https://stackoverflow.com/questions/7489527/ignoring-a-directory-using-acks-ackrc

Can ack find files based on filename only?

為{幸葍}努か 提交于 2019-12-02 17:09:33
Using ack (sometimes packaged as ack-grep) I know that I can find paths that contain a specific string by doing: ack -g somestring But what if I only want files which have "somestring" in their filenames ? You can use find utility. Something like this: find /path/to/look/in -name '*somestring*' -print On some systems, if you omit the path, current directory is used. On other systems you can't omit it, just use . for current directory instead. Also, read man find for many other options. I agree find is the way to go, but you could also easily do it with ack: ack -f | ack "string" Here, "ack -f"