2025-03-14 21:59:59 -06:00
|
|
|
# ack
|
|
|
|
|
|
|
|
|
|
> A search tool like `grep`, optimized for developers.
|
|
|
|
|
> See also: `rg`, which is much faster.
|
|
|
|
|
> More information: <https://beyondgrep.com/documentation>.
|
|
|
|
|
|
|
|
|
|
- Search for files containing a string or regular expression in the current directory recursively:
|
|
|
|
|
|
|
|
|
|
`ack "{{search_pattern}}"`
|
|
|
|
|
|
|
|
|
|
- Search for a case-insensitive pattern:
|
|
|
|
|
|
2025-04-25 19:33:51 -06:00
|
|
|
`ack {{[-i|--ignore-case]}} "{{search_pattern}}"`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
- Search for lines matching a pattern, printing only the matched text and not the rest of the line:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-25 19:33:51 -06:00
|
|
|
`ack {{[-o|--output='$&']}} "{{search_pattern}}"`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Limit search to files of a specific type:
|
|
|
|
|
|
2025-04-25 19:33:51 -06:00
|
|
|
`ack {{[-t|--type]}} {{ruby}} "{{search_pattern}}"`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Do not search in files of a specific type:
|
|
|
|
|
|
2025-04-25 19:33:51 -06:00
|
|
|
`ack {{[-t|--type]}} no{{ruby}} "{{search_pattern}}"`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Count the total number of matches found:
|
|
|
|
|
|
2025-04-25 19:33:51 -06:00
|
|
|
`ack {{[-c|--count]}} {{[-h|--no-filename]}} "{{search_pattern}}"`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Print the file names and the number of matches for each file only:
|
|
|
|
|
|
2025-04-25 19:33:51 -06:00
|
|
|
`ack {{[-c|--count]}} {{[-l|--files-with-matches]}} "{{search_pattern}}"`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- List all the values that can be used with `--type`:
|
|
|
|
|
|
|
|
|
|
`ack --help-types`
|