ag

ack 的升级版,C语言编写,更快更人性化

补充说明

ag命令 它比ack快一个数量级。它会忽略 .gitignore 和 .hgignore 中的文件模式。如果源代码库中有您不想搜索的文件,只需将它们的模式添加到 .ignore 文件即可。命令名称比 ack 短 33%,并且所有键都在 home 行! Github-参考链接

语法

1ag [options] pattern [path ...]
2ag [可选项] 匹配模式 [路径...]

选项

 1Output Options:
 2     --ackmate            以 AckMate-parseable 的格式显示结果
 3  -A --after [LINES]      显示匹配行之后的行(默认2行)
 4  -B --before [LINES]     显示匹配行之前的行(默认2行)
 5     --[no]break          不同文件中匹配到的内容新建一行显示(默认开启)
 6  -c --count              只显示每个文件中匹配到的数量
 7                          (This often differs from the number of matching lines)
 8     --[no]color          Print color codes in results (Enabled by default)
 9     --color-line-number  Color codes for line numbers (Default: 1;33)
10     --color-match        Color codes for result match numbers (Default: 30;43)
11     --color-path         Color codes for path names (Default: 1;32)
12     --column             Print column numbers in results
13     --[no]filename       Print file names (Enabled unless searching a single file)
14  -H --[no]heading        在每个文件匹配前输出文件名(默认开启)
15  -C --context [LINES]    显示匹配行上下两行(默认2行)
16     --[no]group          Same as --[no]break --[no]heading
17  -g --filename-pattern PATTERN
18                          Print filenames matching PATTERN
19  -l --files-with-matches 显示包含匹配的文件名(不显示匹配的行)
20  -L --files-without-matches  只显示不包含匹配项的文件名
21     --print-all-files    Print headings for all files searched, even those that
22                          don\'t contain matches
23     --[no]numbers        Print line numbers. Default is to omit line numbers
24                          when searching streams
25  -o --only-matching      只输出每行匹配的部分
26     --print-long-lines   Print matches on very long lines (Default: >2k characters)
27     --passthrough        When searching a stream, print all lines even if they
28                          don\'t match
29     --silent             Suppress all log messages, including errors
30     --stats              Print stats (files scanned, time taken, etc.)
31     --stats-only         Print stats and nothing else.
32                          (Same as --count when searching a single file)
33     --vimgrep            Print results like vim\'s :vimgrep /pattern/g would
34                          (it reports every match on the line)
35  -0 --null --print0      Separate filenames with null (for 'xargs -0')
36
37Search Options:
38  -a --all-types          搜索所有文件(包括隐藏文件)
39  -D --debug              Ridiculous debugging (probably not useful)
40     --depth NUM          目录搜索最大深度(默认25)
41  -f --follow             跟随链接进行搜索
42  -F --fixed-strings      Alias for --literal for compatibility with grep
43  -G --file-search-regex  根据正则匹配搜索指定类型的文件
44     --hidden             Search hidden files (obeys .*ignore files)
45  -i --ignore-case        Match case insensitively
46     --ignore PATTERN     Ignore files/directories matching PATTERN
47                          (literal file/directory names also allowed)
48     --ignore-dir NAME    Alias for --ignore for compatibility with ack.
49  -m --max-count NUM      在一个文件中最大匹配的数量(默认: 10,000)
50     --one-device         不跟随其他设备的链接搜索
51  -p --path-to-ignore STRING
52                          Use .ignore file at STRING
53  -Q --literal            Don\'t parse PATTERN as a regular expression
54  -s --case-sensitive     Match case sensitively
55  -S --smart-case         Match case insensitively unless PATTERN contains
56                          uppercase characters (Enabled by default)
57     --search-binary      搜索二进制文件
58  -t --all-text           搜索所有文本文件(不包括隐藏文件)
59  -u --unrestricted       搜索所有文件 (忽略 .ignore, .gitignore, etc.;
60                          搜索二进制和隐藏文件)
61  -U --skip-vcs-ignores   Ignore VCS ignore files
62                          (.gitignore, .hgignore; still obey .ignore)
63  -v --invert-match       反向匹配
64  -w --word-regexp        只匹配整个单词
65  -W --width NUM          Truncate match lines after NUM characters
66  -z --search-zip         搜索压缩文件中的内容
67
68File Types:
69The search can be restricted to certain types of files. Example:
70  ag --html needle   结果输出到指定类型文件
71  - Searches for 'needle' in files with suffix .htm, .html, .shtml or .xhtml.
72
73For a list of supported file types run:
74  ag --list-file-types  列出支持的文件类型

实例

列出当前目录下包含 npm 的文件

1➜  vue-project ag npm ./
2README.md
316:npm install
422:npm run dev
528:npm run build

来源:https://github.com/jaywcjlove/linux-command

相关文章:

翻译: