2014-10-02 02:02:25 +04:00
|
|
|
# ack
|
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
> A search tool like grep, optimized for developers.
|
|
|
|
> See also: `rg`, which is much faster.
|
|
|
|
> More information: <https://beyondgrep.com/documentation>.
|
2014-10-02 02:02:25 +04:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
- Search for files containing a string or regular expression in the current directory recursively:
|
2014-10-02 02:02:25 +04:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
`ack "{{search_pattern}}"`
|
2014-10-02 02:02:25 +04:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
- Search for a case-insensitive pattern:
|
2014-10-02 02:02:25 +04:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
`ack --ignore-case "{{search_pattern}}"`
|
2014-10-02 02:02:25 +04:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
- Search for lines matching a pattern, printing [o]nly the matched text and not the rest of the line:
|
2014-10-02 02:02:25 +04:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
`ack -o "{{search_pattern}}"`
|
2014-10-02 02:02:25 +04:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
- Limit search to files of a specific type:
|
2014-10-02 02:02:25 +04:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
`ack --type={{ruby}} "{{search_pattern}}`
|
2019-03-07 11:23:13 +03:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
- Do not search in files of a specific type:
|
2020-05-11 11:57:08 +03:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
`ack --type=no{{ruby}} "{{search_pattern}}`
|
2020-05-11 11:57:08 +03:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
- Count the total number of matches found:
|
2020-05-11 11:57:08 +03:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
`ack --count --no-filename "{{search_pattern}}"`
|
2020-05-11 11:57:08 +03:00
|
|
|
|
2021-03-25 02:50:01 +03:00
|
|
|
- Print the file names and the number of matches for each file only:
|
|
|
|
|
|
|
|
`ack --count --files-with-matches "{{search_pattern}}"`
|
|
|
|
|
|
|
|
- List all values that can be used with `--type`:
|
2019-03-07 11:23:13 +03:00
|
|
|
|
2020-07-17 00:33:06 +03:00
|
|
|
`ack --help-types`
|