.\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . .TH "AG" "1" "December 2016" "" "" . .SH "NAME" \fBag\fR \- The Silver Searcher\. Like ack, but faster\. . .SH "SYNOPSIS" \fBag\fR [\fIoptions\fR] \fIpattern\fR [\fIpath \.\.\.\fR] . .SH "DESCRIPTION" Recursively search for PATTERN in PATH\. Like grep or ack, but faster\. . .SH "OPTIONS" . .TP \fB\-\-ackmate\fR Output results in a format parseable by AckMate \fIhttps://github\.com/protocool/AckMate\fR\. . .TP \fB\-\-[no]affinity\fR Set thread affinity (if platform supports it)\. Default is true\. . .TP \fB\-a \-\-all\-types\fR Search all files\. This doesn\'t include hidden files, and doesn\'t respect any ignore files\. . .TP \fB\-A \-\-after [LINES]\fR Print lines after match\. If not provided, LINES defaults to 2\. . .TP \fB\-B \-\-before [LINES]\fR Print lines before match\. If not provided, LINES defaults to 2\. . .TP \fB\-\-[no]break\fR Print a newline between matches in different files\. Enabled by default\. . .TP \fB\-c \-\-count\fR Only print the number of matches in each file\. Note: This is the number of matches, \fBnot\fR the number of matching lines\. Pipe output to \fBwc \-l\fR if you want the number of matching lines\. . .TP \fB\-\-[no]color\fR Print color codes in results\. Enabled by default\. . .TP \fB\-\-color\-line\-number\fR Color codes for line numbers\. Default is 1;33\. . .TP \fB\-\-color\-match\fR Color codes for result match numbers\. Default is 30;43\. . .TP \fB\-\-color\-path\fR Color codes for path names\. Default is 1;32\. . .TP \fB\-\-column\fR Print column numbers in results\. . .TP \fB\-C \-\-context [LINES]\fR Print lines before and after matches\. Default is 2\. . .TP \fB\-D \-\-debug\fR Output ridiculous amounts of debugging info\. Not useful unless you\'re actually debugging\. . .TP \fB\-\-depth NUM\fR Search up to NUM directories deep, \-1 for unlimited\. Default is 25\. . .TP \fB\-\-[no]filename\fR Print file names\. Enabled by default, except when searching a single file\. . .TP \fB\-f \-\-[no]follow\fR Follow symlinks\. Default is false\. . .TP \fB\-F \-\-fixed\-strings\fR Alias for \-\-literal for compatibility with grep\. . .TP \fB\-\-[no]group\fR The default, \fB\-\-group\fR, lumps multiple matches in the same file together, and presents them under a single occurrence of the filename\. \fB\-\-nogroup\fR refrains from this, and instead places the filename at the start of each match line\. . .TP \fB\-g PATTERN\fR Print filenames matching PATTERN\. . .TP \fB\-G \-\-file\-search\-regex PATTERN\fR Only search files whose names match PATTERN\. . .TP \fB\-H \-\-[no]heading\fR Print filenames above matching contents\. . .TP \fB\-\-hidden\fR Search hidden files\. This option obeys ignored files\. . .TP \fB\-\-ignore PATTERN\fR Ignore files/directories whose names match this pattern\. Literal file and directory names are also allowed\. . .TP \fB\-\-ignore\-dir NAME\fR Alias for \-\-ignore for compatibility with ack\. . .TP \fB\-i \-\-ignore\-case\fR Match case\-insensitively\. . .TP \fB\-l \-\-files\-with\-matches\fR Only print the names of files containing matches, not the matching lines\. An empty query will print all files that would be searched\. . .TP \fB\-L \-\-files\-without\-matches\fR Only print the names of files that don\'t contain matches\. . .TP \fB\-\-list\-file\-types\fR See \fBFILE TYPES\fR below\. . .TP \fB\-m \-\-max\-count NUM\fR Skip the rest of a file after NUM matches\. Default is 0, which never skips\. . .TP \fB\-\-[no]mmap\fR Toggle use of memory\-mapped I/O\. Defaults to true on platforms where \fBmmap()\fR is faster than \fBread()\fR\. (All but macOS\.) . .TP \fB\-\-[no]multiline\fR Match regexes across newlines\. Enabled by default\. . .TP \fB\-n \-\-norecurse\fR Don\'t recurse into directories\. . .TP \fB\-\-[no]numbers\fR Print line numbers\. Default is to omit line numbers when searching streams\. . .TP \fB\-o \-\-only\-matching\fR Print only the matching part of the lines\. . .TP \fB\-\-one\-device\fR When recursing directories, don\'t scan dirs that reside on other storage devices\. This lets you avoid scanning slow network mounts\. This feature is not supported on all platforms\. . .TP \fB\-p \-\-path\-to\-ignore STRING\fR Provide a path to a specific \.ignore file\. . .TP \fB\-\-pager COMMAND\fR Use a pager such as \fBless\fR\. Use \fB\-\-nopager\fR to override\. This option is also ignored if output is piped to another program\. . .TP \fB\-\-parallel\fR Parse the input stream as a search term, not data to search\. This is meant to be used with tools such as GNU parallel\. For example: \fBecho "foo\enbar\enbaz" | parallel "ag {} \."\fR will run 3 instances of ag, searching the current directory for "foo", "bar", and "baz"\. . .TP \fB\-\-print\-long\-lines\fR Print matches on very long lines (> 2k characters by default)\. . .TP \fB\-\-passthrough \-\-passthru\fR When searching a stream, print all lines even if they don\'t match\. . .TP \fB\-Q \-\-literal\fR Do not parse PATTERN as a regular expression\. Try to match it literally\. . .TP \fB\-r \-\-recurse\fR Recurse into directories when searching\. Default is true\. . .TP \fB\-s \-\-case\-sensitive\fR Match case\-sensitively\. . .TP \fB\-S \-\-smart\-case\fR Match case\-sensitively if there are any uppercase letters in PATTERN, case\-insensitively otherwise\. Enabled by default\. . .TP \fB\-\-search\-binary\fR Search binary files for matches\. . .TP \fB\-\-silent\fR Suppress all log messages, including errors\. . .TP \fB\-\-stats\fR Print stats (files scanned, time taken, etc)\. . .TP \fB\-\-stats\-only\fR Print stats (files scanned, time taken, etc) and nothing else\. . .TP \fB\-t \-\-all\-text\fR Search all text files\. This doesn\'t include hidden files\. . .TP \fB\-u \-\-unrestricted\fR Search \fIall\fR files\. This ignores \.ignore, \.gitignore, etc\. It searches binary and hidden files as well\. . .TP \fB\-U \-\-skip\-vcs\-ignores\fR Ignore VCS ignore files (\.gitignore, \.hgignore), but still use \.ignore\. . .TP \fB\-v \-\-invert\-match\fR Match every line \fInot\fR containing the specified pattern\. . .TP \fB\-V \-\-version\fR Print version info\. . .TP \fB\-\-vimgrep\fR Output results in the same form as Vim\'s \fB:vimgrep /pattern/g\fR . .IP Here is a ~/\.vimrc configuration example: . .IP \fBset grepprg=ag\e \-\-vimgrep\e $*\fR \fBset grepformat=%f:%l:%c:%m\fR . .IP Then use \fB:grep\fR to grep for something\. Then use \fB:copen\fR, \fB:cn\fR, \fB:cp\fR, etc\. to navigate through the matches\. . .TP \fB\-w \-\-word\-regexp\fR Only match whole words\. . .TP \fB\-\-workers NUM\fR Use NUM worker threads\. Default is the number of CPU cores, with a max of 8\. . .TP \fB\-z \-\-search\-zip\fR Search contents of compressed files\. Currently, gz and xz are supported\. This option requires that ag is built with lzma and zlib\. . .TP \fB\-0 \-\-null \-\-print0\fR Separate the filenames with \fB\e0\fR, rather than \fB\en\fR: this allows \fBxargs \-0 \fR to correctly process filenames containing spaces or newlines\. . .SH "FILE TYPES" It is possible to restrict the types of files searched\. For example, passing \fB\-\-html\fR will search only files with the extensions \fBhtm\fR, \fBhtml\fR, \fBshtml\fR or \fBxhtml\fR\. For a list of supported types, run \fBag \-\-list\-file\-types\fR\. . .SH "IGNORING FILES" By default, ag will ignore files whose names match patterns in \.gitignore, \.hgignore, or \.ignore\. These files can be anywhere in the directories being searched\. Binary files are ignored by default as well\. Finally, ag looks in $HOME/\.agignore for ignore patterns\. . .P If you want to ignore \.gitignore and \.hgignore, but still take \.ignore into account, use \fB\-U\fR\. . .P Use the \fB\-t\fR option to search all text files; \fB\-a\fR to search all files; and \fB\-u\fR to search all, including hidden files\. . .SH "EXAMPLES" \fBag printf\fR: Find matches for "printf" in the current directory\. . .P \fBag foo /bar/\fR: Find matches for "foo" in path /bar/\. . .P \fBag \-\- \-\-foo\fR: Find matches for "\-\-foo" in the current directory\. (As with most UNIX command line utilities, "\-\-" is used to signify that the remaining arguments should not be treated as options\.) . .SH "ABOUT" ag was originally created by Geoff Greer\. More information (and the latest release) can be found at http://geoff\.greer\.fm/ag . .SH "SEE ALSO" grep(1)