Questions tagged [ag]
17 questions
62
votes
2 answers
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 extensions? I tried this:
localhost:workspace…
Dave
- 2,348
- 21
- 54
- 84
16
votes
1 answer
How is ripgrep different from silver searcher ag?
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
- 351
- 1
- 3
- 10
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
6
votes
2 answers
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
find -L $HOME -xtype f -name "*.tex" \
-exec…
Léo Léopold Hertz 준영
- 6,788
- 29
- 91
- 193
3
votes
2 answers
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 it should work as ag implements PCRE syntax,…
ninrod
- 379
- 2
- 13
3
votes
1 answer
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 like getWhile().
cat ~/reservedjava.txt |…
djeikyb
- 348
- 1
- 10
2
votes
2 answers
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-empty
+ravi@boxy:~/new$
How do I get empty to appear in the example…
Tom Hale
- 28,728
- 32
- 139
- 229
1
vote
0 answers
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:
x
x
x x b c x x
x
x
file7:
x
x
x x b b x…
Daniel Kaplan
- 757
- 10
- 25
1
vote
1 answer
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.production
REACT_APP_PROXY=https://map.chicommons.coop
but when…
Dave
- 2,348
- 21
- 54
- 84
1
vote
0 answers
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 behaviour isn't what I expect.
$ ag aStar
finds no…
Neil Smith
- 111
- 1
1
vote
0 answers
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 that the project directories will include other…
Kris
- 235
- 1
- 4
- 10
1
vote
1 answer
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 I don't understand this is also matching blank…
Andrew
- 113
- 4
0
votes
0 answers
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 "$@") || /usr/bin/ag; }
This works fine, but if I try to…
lkraav
- 1,161
- 2
- 11
- 20
0
votes
0 answers
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.
Basically, it should match any line optionally starting…
k0pernikus
- 14,853
- 21
- 58
- 79
0
votes
3 answers
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 search for pattern TODO: it should only print result…
cevhyruz
- 417
- 4
- 15