Questions tagged [ack]

ACK is a greplike tool optimized for programmers searching large heterogeneous trees of source code.

ACK 2 is a code-searching tool, similar to grep but optimized for programmers searching large trees of source code. It runs in pure Perl, is highly portable, and runs on any platform that runs Perl.
Source official git page

37 questions
59
votes
9 answers

Search only in files that match a pattern with ack

Can ack search only through files that match a specific 'glob' pattern (eg: search for foo in all files named "bar*.c"). The command ack foo "bar*.c" only works in the current directory. Note: I know it's possible with find -exec: find . -name…
compie
  • 783
  • 1
  • 5
  • 8
58
votes
4 answers

How to do max-depth search in ack and grep?

Is there any way to tell ack to only search for text on the current folder? (or specify a max-depth level?) And with grep?
Amelio Vazquez-Reina
  • 40,169
  • 77
  • 197
  • 294
19
votes
3 answers

`ack` doesn't show line numbers on a single file

I'm using ack to search for a string. When I run it without a file argument, I get line numbers: $> ack function themes/README.txt 7:Drupal's sub-theme functionality to ensure easy maintenance and upgrades. sites/default/default.services.yml 48: …
user394
  • 14,194
  • 21
  • 66
  • 93
15
votes
3 answers

How to ignore multiple files with `ag` The Silver Searcher

There is an option --ignore which allows specifying files to ignore. At the moment I only managed to ignore multiple files by doing --ignore file1 --ignore file2....... Trying to use --ignore "*assets*|*scripts*" does nothing. So is there a catch…
T.Chmelevskij
  • 253
  • 1
  • 2
  • 7
14
votes
2 answers

Search ALL files with ack

How can I search all files (including binary) in the current directory with ack v2? I want to do the same as doing ack 'foo' **, but just with a flag, so it works if I want to search all files in a specific directory without appending…
Tyilo
  • 5,891
  • 12
  • 47
  • 61
10
votes
2 answers

How do I ack-grep exclude file type *.sql files or file size larger than >3MB?

I want to search my directory for "foo" in the files, but i have these gigantic sql files. How do I exclude these file types or file sizes larger than 3MB using ack-grep? Also how would this be done with grep?
Patoshi パトシ
  • 1,695
  • 6
  • 24
  • 34
8
votes
2 answers

ack/grep search and sort by modification date

Is there any way to have ack sort the results found by date of modification? (ideally showing the date next to the result?). It doesn't look like ack has a date option, but just in case. If this isn't possible with ack, how about grep or using a…
Josh
  • 1,694
  • 3
  • 16
  • 32
4
votes
2 answers

ack : get the 10th (or bigger nth) matching/capturing group

I think I might have just searched wrong, but I didn't find any answer. If there's a duplicate, please just let me know, and I can take this down. Problem Background I'm using ack (link), which has Perl 5 under the hood, to get n-grams - especially…
bballdave025
  • 242
  • 2
  • 13
4
votes
2 answers

Is there `find`'s `-exec` like option in `ack-grep`?

I want to remove all texts that include string foo. I can list all files by ack-grep foo, but I couldn't find a way to remove all files like -exec rm {} option like find. How can I delete all files that contains particular string?
ironsand
  • 5,085
  • 12
  • 50
  • 73
4
votes
2 answers

How to search all text files in Ack? (with --text option being now removed)

Manual says that "The --text option has been removed.". It was setting the --type to text, i.e. ack was searching all text files regardless of their semantic category (i.e. in *.php files, *.txt files, *.cpp files, etc.). How to obtain this behavior…
Jerry Epas
  • 349
  • 3
  • 11
3
votes
1 answer

Ignore files without extension in ack

I would like to define a file type that would enable me to ignore all files without extension in ack. In my .ackrc file I have added: --type-set=csv:ext:csv,tsv To handle CSV files that I often exclude from searches via --nocsv switch when running…
Konrad
  • 313
  • 1
  • 8
3
votes
0 answers

Using ack to effectively search and RStudio project directory

I'm interested in running ack search on a RStudio project directory that mostly contains *.R script files but also some project files and often *.git files. Directory The project folder structure created from a default Shiny application: $…
Konrad
  • 313
  • 1
  • 8
3
votes
1 answer

ack.pl tool and ack.pl flags

I am using the ack.pl tool in order to search string or IP’s in files The official site of ack.pl is - http://beyondgrep.com/documentation/ Example of ack.pl CLI ( want to find the string STRING_TO_FIND in files under /etc ) /tmp/ack.pl -Q -a -l…
maihabunash
  • 6,973
  • 19
  • 64
  • 80
2
votes
2 answers

Why Doesn't This Shell Script Work?

I've got the following shell script #!/bin/bash # Search elixir code with ack # By default skip the dependencies and test directories ignore_dirs=("dependencies" "test" "config") # the for call below inserts newlines so we need to strip them out…
2
votes
1 answer

Can ack read patterns from a file?

grep can look for a list of patterns written in a file with grep -f patterns_file search_files Can ack read a list of patterns from a file?
lolesque
  • 291
  • 1
  • 10
1
2 3