1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/common/ack.md

38 lines
983 B
Markdown
Raw Normal View History

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