UNPKG

5.21 kBMarkdownView Raw
1ag
2===
3
4ack 的升级版,C语言编写,更快更人性化
5
6## 补充说明
7
8**ag命令** 它比ack快一个数量级。它会忽略 .gitignore 和 .hgignore 中的文件模式。如果源代码库中有您不想搜索的文件,只需将它们的模式添加到 .ignore 文件即可。命令名称比 ack 短 33%,并且所有键都在 home 行!
9[Github-参考链接](https://github.com/ggreer/the_silver_searcher)
10
11### 语法
12
13```shell
14ag [options] pattern [path ...]
15ag [可选项] 匹配模式 [路径...]
16```
17
18### 选项
19
20```shell
21Output Options:
22 --ackmate 以 AckMate-parseable 的格式显示结果
23 -A --after [LINES] 显示匹配行之后的行(默认2行)
24 -B --before [LINES] 显示匹配行之前的行(默认2行)
25 --[no]break 不同文件中匹配到的内容新建一行显示(默认开启)
26 -c --count 只显示每个文件中匹配到的数量
27 (This often differs from the number of matching lines)
28 --[no]color Print color codes in results (Enabled by default)
29 --color-line-number Color codes for line numbers (Default: 1;33)
30 --color-match Color codes for result match numbers (Default: 30;43)
31 --color-path Color codes for path names (Default: 1;32)
32 --column Print column numbers in results
33 --[no]filename Print file names (Enabled unless searching a single file)
34 -H --[no]heading 在每个文件匹配前输出文件名(默认开启)
35 -C --context [LINES] 显示匹配行上下两行(默认2行)
36 --[no]group Same as --[no]break --[no]heading
37 -g --filename-pattern PATTERN
38 Print filenames matching PATTERN
39 -l --files-with-matches 显示包含匹配的文件名(不显示匹配的行)
40 -L --files-without-matches 只显示不包含匹配项的文件名
41 --print-all-files Print headings for all files searched, even those that
42 don\'t contain matches
43 --[no]numbers Print line numbers. Default is to omit line numbers
44 when searching streams
45 -o --only-matching 只输出每行匹配的部分
46 --print-long-lines Print matches on very long lines (Default: >2k characters)
47 --passthrough When searching a stream, print all lines even if they
48 don\'t match
49 --silent Suppress all log messages, including errors
50 --stats Print stats (files scanned, time taken, etc.)
51 --stats-only Print stats and nothing else.
52 (Same as --count when searching a single file)
53 --vimgrep Print results like vim\'s :vimgrep /pattern/g would
54 (it reports every match on the line)
55 -0 --null --print0 Separate filenames with null (for 'xargs -0')
56
57Search Options:
58 -a --all-types 搜索所有文件(包括隐藏文件)
59 -D --debug Ridiculous debugging (probably not useful)
60 --depth NUM 目录搜索最大深度(默认25)
61 -f --follow 跟随链接进行搜索
62 -F --fixed-strings Alias for --literal for compatibility with grep
63 -G --file-search-regex 根据正则匹配搜索指定类型的文件
64 --hidden Search hidden files (obeys .*ignore files)
65 -i --ignore-case Match case insensitively
66 --ignore PATTERN Ignore files/directories matching PATTERN
67 (literal file/directory names also allowed)
68 --ignore-dir NAME Alias for --ignore for compatibility with ack.
69 -m --max-count NUM 在一个文件中最大匹配的数量(默认: 10,000)
70 --one-device 不跟随其他设备的链接搜索
71 -p --path-to-ignore STRING
72 Use .ignore file at STRING
73 -Q --literal Don\'t parse PATTERN as a regular expression
74 -s --case-sensitive Match case sensitively
75 -S --smart-case Match case insensitively unless PATTERN contains
76 uppercase characters (Enabled by default)
77 --search-binary 搜索二进制文件
78 -t --all-text 搜索所有文本文件(不包括隐藏文件)
79 -u --unrestricted 搜索所有文件 (忽略 .ignore, .gitignore, etc.;
80 搜索二进制和隐藏文件)
81 -U --skip-vcs-ignores Ignore VCS ignore files
82 (.gitignore, .hgignore; still obey .ignore)
83 -v --invert-match 反向匹配
84 -w --word-regexp 只匹配整个单词
85 -W --width NUM Truncate match lines after NUM characters
86 -z --search-zip 搜索压缩文件中的内容
87
88File Types:
89The search can be restricted to certain types of files. Example:
90 ag --html needle 结果输出到指定类型文件
91 - Searches for 'needle' in files with suffix .htm, .html, .shtml or .xhtml.
92
93For a list of supported file types run:
94 ag --list-file-types 列出支持的文件类型
95```
96
97### 实例
98
99列出当前目录下包含 `npm` 的文件
100
101```shell
102➜ vue-project ag npm ./
103README.md
10416:npm install
10522:npm run dev
10628:npm run build
107```
108