Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [ag]

For questions on `ag` (a.k.a. The Silver Searcher), a RegEx-based code-searching tool optimized for speed.

Filter by
Sorted by
Tagged with
1 vote
2 answers
170 views

How can I limit the file size of files searched by ag?

I don't want ag to search files larger than 2Mio. I can't find anything like a --file-size flag to the ag command, but is there any way to tell it that? I'm getting lots of ERR: Skipping foo.bar: ...
Jason Hunter's user avatar
1 vote
0 answers
233 views

How can I recursively search file contents by ANDed patterns and print the output like ag/the silver searcher would?

This will be easier to explain via example. Here are my input files: file1: x x a b c x x file2: x x c b a x x file3: x x x x a b c x x x x file4: x x x x c b a x x x x file5: x x a b x x file6: ...
Daniel Kaplan's user avatar
1 vote
1 answer
188 views

How do I configure ag so that it will also search for files beginning with a "."?

I'm using ag v 2.2. How do I configure ag so that it will search for files beginning with a "." in addition to all other files? I'm noticing I have a file like so $ cat client/.env....
Dave's user avatar
  • 2,578
0 votes
0 answers
92 views

How to get shell TAB-completion to work when I redirect grep ag ack output to vim?

I define ag as bash function, to make usage relatively transparent ag() { [ $# -gt 0 ] && vim -c silent\ SyntasticToggleMode -c copen -q <(/usr/bin/ag --silent --vimgrep --nogroup "$@&...
lkraav's user avatar
  • 1,181
1 vote
0 answers
131 views

How to make ag search "non-standard" langauge files?

I'm using Silver Searcher, ag, version 2.1.0 on Ubuntu. I'm trying to search for the string aStar in Haskell files in the current directory tree. (The files are text files with extension .hs.) The ...
Neil Smith's user avatar
0 votes
0 answers
158 views

How to create a regex matching a custom string at the beginning of line while ignoring all preceding whitespaces via ag silversearcher?

Give an example file with the content: // find me val ignore me = "" // I should not be found // find me // find me I want to find all the lines with find me using ag silversearcher. ...
k0pernikus's user avatar
  • 15.6k
0 votes
3 answers
49 views

Is it possible to print a search pattern result just until it hits a blank newline in terminal?

Say for example I have a file with contents like this: # TODO: Optimize this. alias bash='start bash' # FIXME: Just fix this. alias fix='there is something wrong with this What I want is if I ...
cevhyruz's user avatar
  • 437
18 votes
1 answer
11k views

How is ripgrep different from silver searcher ag? [closed]

Are these related? Which is faster? Can either be limited to directory-names? https://github.com/BurntSushi/ripgrep https://github.com/ggreer/the_silver_searcher
johny why's user avatar
  • 371
0 votes
1 answer
1k views

search with and without a pattern with ag

With two files with echo 'example.com/call_me?param' > file1.txt echo 'example.com/call_me_maybe?param' >> file1.txt echo 'example.com/call_me?' >> file1.txt echo 'example.com/call_me?...
PockPock's user avatar
  • 103
1 vote
0 answers
45 views

Can ag search sub-directories with the same name, within a bunch of directories?

Given a directory structure such as: dev/project1/assets/** dev/project2/assets/** dev/project3/assets/** Is it possible to search, from within the dev directory all assets directories only. Given ...
Kris's user avatar
  • 245
0 votes
1 answer
392 views

Ack/Ag does not return search result without *

I am trying to search text in a directory and it turned out that the following syntaxes do not return any result ack -i "0xabcdef" ./ ack -i "0xabcdef" ack -i "0xabcdef" . while the following ...
user2065276's user avatar
16 votes
4 answers
12k views

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 "*...
T.Chmelevskij's user avatar
69 votes
2 answers
41k views

How do I use ag to look for text in files with certain extensions?

I'm using ag (The Silver Searcher) version 0.31.0. I can easily look for a string in a bunch of files using: localhost:workspace davea$ ag 'ftp' . But what if I only want to scan files with certain ...
Dave's user avatar
  • 2,578
6 votes
2 answers
871 views

How to make this search faster in fgrep/Ag?

I am thinking methods to make the search faster and/or better which principally uses fgrep or ag. Code which searches the word and case-insensitively at $HOME, and redirects a list of matches to vim ...
Léo Léopold Hertz 준영's user avatar
2 votes
2 answers
365 views

How do I force ag (the silver searcher) to list empty files

How do I get ag to list all files, including empty ones? +ravi@boxy:~$ mkdir new && cd new +ravi@boxy:~/new$ echo stuff > non-empty && touch empty +ravi@boxy:~/new$ ag -ul non-...
Tom Hale's user avatar
  • 30.8k
3 votes
2 answers
1k views

how to issue a `start of string` pattern for ag

I want to find every file in from the current dir and downwards whose filename starts with foo using ag(the silver searcher). I have tried: ag -g '^foo' ag -g '\^foo' ag -g '\Afoo' no luck. But ...
ninrod's user avatar
  • 389
1 vote
1 answer
454 views

Why is ag printing blank lines from this file?

I want to use ag to print the classes and their methods in a python file. I thought that this would be easy using: ag --context=0 --nocolor -os '^\s*(def|class)\s+[_A-Za-z]*' prog.py but for reasons ...
Andrew's user avatar
  • 113
3 votes
1 answer
437 views

No output using parallel in tandem with ag or ack

I have a list of java reserved words, first letter capitalised. $ tail -n5 ~/reservedjava.txt Break While True False Null I'm trying to look through all my java source code to find methods that look ...
djeikyb's user avatar
  • 348