tldr/pages/common/ack.md

38 lines
977 B
Markdown
Raw Normal View History

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}}`
2021-03-25 02:50:01 +03:00
- Do not search in files of a specific type:
2021-03-25 02:50:01 +03:00
`ack --type=no{{ruby}} "{{search_pattern}}`
2021-03-25 02:50:01 +03:00
- Count the total number of matches found:
2021-03-25 02:50:01 +03:00
`ack --count --no-filename "{{search_pattern}}"`
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`:
2020-07-17 00:33:06 +03:00
`ack --help-types`