An upgraded version of ack, written in C language, faster and more user-friendly
ag [options] pattern [path ...]
ag [optional] match pattern [path...]
Output options:
--ackmate Display results in AckMate-parseable format
-A --after [LINES] Display the lines after the matching line (default 2 lines)
-B --before [LINES] Display lines before matching line (default 2 lines)
--[no]break Create a new line to display the matched content in different files (enabled by default)
-c --count Show only the number of matches in each file (usually different from the number of matched lines)
--[no]color Print color codes in results (enabled by default)
--color-line-number Color code for line number (default: 1;33).
--color-match Color code of matching results (default: 30;43).
--color-path Color code for path name (default: 1;32)
--column print the column number in the results
--[no]filename Print filename (enabled unless searching for a single file).
-H --[no]heading Output file name before each file match (enabled by default)
-C --context [LINES] Display two lines above and below the matching line (default 2 lines)
--[no]group Same as these: --[no]break --[no]heading
-g --filename-pattern PATTERN prints file names matching PATTERN
-l --files-with-matches Display file names containing matches (do not display matching lines)
-L --files-without-matches Show only file names without matches
--print-all-files Print the titles of all searched files, even those that contain no matches.
--[no]numbers Print line numbers. The default is to omit line numbers when searching streams.
-o --only-matching Output only the matching part of each line
--print-long-lines Print match information on very long lines (default: >2k characters).
--passthrough When searching a stream, print all lines, even if they don't match.
--silent suppresses all log messages, including errors
--stats Print statistics (files scanned, time spent, etc.).
--stats-only prints statistics and no other information (same as --count when searching for a single file).
--vimgrep prints results like vim's :vimgrep /pattern/g (it reports matches for each line)
-0 --null --print0 Null-separated file names (for 'xargs -0').
Search options:
-a --all-types Search all files (including hidden files)
-D --debug Ridiculous debugging (probably useless)
--depth NUM directory search maximum depth (default 25)
-f --follow follow the link to search
-F --fixed-strings For compatibility with grep, alias for --literal.
-G --file-search-regex Search for files of the specified type based on regular matching
--hidden Search for hidden files (but respect .*ignore files)
-i --ignore-case case-insensitive matching
--ignore PATTERN ignore files/directories matching PATTERN (text file/directory names are also allowed)
--ignore-dir NAME Alias for --ignore for compatibility with ack
-m --max-count NUM Maximum number of matches in a file (default: 10,000)
--one-device Do not follow link searches for other devices
-p --path-to-ignore STRING Use .ignore file in STRING
-Q --literal Do not parse PATTERN as a regular expression
-s --case-sensitive match cases sensitively
-S --smart-case Case-insensitive matching unless PATTERN contains uppercase characters
--search-binary Search binary files
-t --all-text Search all text files (excluding hidden files)
-u --unrestricted Search all files (ignore .ignore, .gitignore, e.g. search binary and hidden files)
-U --skip-vcs-ignores Ignore VCS ignore files (referring to .gitignore, .hgignore; still comply with .ignore).
-v --invert-match reverse match
-w --word-regexp matches only whole words
-W --width NUM truncate matching lines after NUM characters
-z --search-zip Search the contents of compressed files
file type:
Searches can be limited to certain types of files, for example:
ag --html needle outputs the results to the specified type of file
- Search for "needle" in files with the .htm, .html, .shtml or .xhtml suffix
For a list of supported file types, run:
ag --list-file-types List supported file types
List files containing npm
in the current directory
➜ vue-project ag npm ./
README.md
16: npm install
22: npm run dev
28: npm run build