ag [command] [command...]

Recursively search for PATTERN in PATH. Like grep or ack, but faster




--ackmateOutput results in a format parseable by AckMate
--affinitySet thread affinity (if platform supports it)
--noaffinityDon't set thread affinity (if platform supports it)
-a,--all-typesSearch all files. This doesn't include hidden files, and doesn't respect any ignore files
-A,--after [command]Print lines after match
-B,--before [command]Print lines before match
--nobreakPrint a newline between matches in different files. Enabled by default
-c,--countOnly print the number of matches in each file. Note: This is the number of matches, not the number of matching lines. Pipe output to wc -l if you want the number of matching lines
--colorPrint color codes in results
--nocolorDon't print color codes in results
--color-line-numberColor codes for line numbers. Default is 1;33
--color-matchColor codes for result match numbers. Default is 30;43
--color-pathColor codes for path names. Default is 1;32
--columnPrint column numbers in results
-C,--context [command]Print lines before and after matches
-D,--debugOutput ridiculous amounts of debugging info. Not useful unless you're actually debugging
--depth [command]Search up to NUM directories deep, -1 for unlimited
--filenamePrint file names
--nofilenameDon't print file names
-f,--followFollow symlinks
--nofollowDon't follow symlinks
-F,--fixed-stringsAlias for --literal for compatibility with grep
--groupLumps multiple matches in the same file together, and presents them under a single occurrence of the filename
--nogroupRefrains from lumping matches in the same file together, and instead places the filename at the start of each match line
-g <command>Print filenames matching PATTERN
-G,--file-search-regex <command>Only search files whose names match PATTERN
-H,--headingPrint filenames above matching contents
--noheadingDon't print filenames above matching contents
--hiddenSearch hidden files. This option obeys ignored files
--ignore <command>Ignore files/directories whose names match this pattern. Literal file and directory names are also allowed
--ignore-dir <command>Alias for --ignore for compatibility with ack
-i,--ignore-caseMatch case-insensitively
-l,--files-with-matchesOnly print the names of files containing matches, not the matching lines. An empty query will print all files that would be searched
-L,--files-without-matchesOnly print the names of files that don't contain matches
--list-file-typesSee FILE TYPES below
-m,--max-count [command]Skip the rest of a file after NUM matches. Default is 0, which never skips
--mmapUse of memory-mapped I/O. Defaults to true on platforms where mmap() is faster than read(). (All but macOS.)
--nommapDon't use of memory-mapped I/O. Defaults to true on platforms where mmap() is faster than read(). (All but macOS.)
--multilineMatch regexes across newlines
--nomultilineDon't match regexes across newlines
-n,--norecurseDon't recurse into directories
--numbersPrint line numbers
--nonumbersDon't print line numbers
-o,--only-matchingPrint only the matching part of the lines
--one-deviceWhen 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
-p,--path-to-ignore <command>Provide a path to a specific .ignore file
--pager <command>Use a pager such as less. Use --nopager to override. This option is also ignored if output is piped to another program
--parallelParse 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: echo "foo bar baz" | parallel "ag {} ." will run 3 instances of ag, searching the current directory for "foo", "bar", and "baz"
--print-long-linesPrint matches on very long lines (> 2k characters by default)
--passthrough,--passthruWhen searching a stream, print all lines even if they don't match
-Q,--literalDo not parse PATTERN as a regular expression. Try to match it literally
-r,--recurseRecurse into directories when searching. Default is true
-s,--case-sensitiveMatch case-sensitively
-S,--smart-caseMatch case-sensitively if there are any uppercase letters in PATTERN, case-insensitively otherwise. Enabled by default
--search-binarySearch binary files for matches
--silentSuppress all log messages, including errors
--statsPrint stats (files scanned, time taken, etc)
--stats-onlyPrint stats (files scanned, time taken, etc) and nothing else
-t,--all-textSearch all text files. This doesn't include hidden files
-u,--unrestrictedSearch all files. This ignores .ignore, .gitignore, etc. It searches binary and hidden files as well
-U,--skip-vcs-ignoresIgnore VCS ignore files (.gitignore, .hgignore), but still use .ignore
-v,--invert-matchMatch every line not containing the specified pattern
-V,--versionPrint version info
--vimgrepOutput results in the same form as Vim's :vimgrep /pattern/g Here is a ~/.vimrc configuration example: set grepprg=ag --vimgrep $* set grepformat=%f:%l:%c:%m Then use :grep to grep for something. Then use :copen, :cn, :cp, etc. to navigate through the matches
-w,--word-regexpOnly match whole words
--workers [command]Use NUM worker threads. Default is the number of CPU cores, with a max of 8
-z,--search-zipSearch contents of compressed files. Currently, gz and xz are supported. This option requires that ag is built with lzma and zlib
-0,--null,--print0Separate the filenames with , rather than : this allows xargs -0 <command> to correctly process filenames containing spaces or newlines