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
1 KiB
Markdown
Raw Normal View History

2014-10-01 18:02:25 -04:00
# ack
> A search tool like `grep`, optimized for developers.
2021-03-24 19:50:01 -04:00
> 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
`ack {{[-i|--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
`ack {{[-o|--output='$&']}} "{{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
`ack {{[-t|--type]}} {{ruby}} "{{search_pattern}}"`
2021-03-24 19:50:01 -04:00
- Do not search in files of a specific type:
`ack {{[-t|--type]}} no{{ruby}} "{{search_pattern}}"`
2021-03-24 19:50:01 -04:00
- Count the total number of matches found:
`ack {{[-c|--count]}} {{[-h|--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 {{[-c|--count]}} {{[-l|--files-with-matches]}} "{{search_pattern}}"`
2021-03-24 19:50:01 -04:00
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`