Questions tagged [ag]

The Silver Searcher, better known as Ag is a tool similar to ack.

The Silver Searcher, better known as Ag is an open-source tool similar to created and maintained by Geoff Greer.

115 questions
3
votes
1 answer

Silversearcher/ack vs find,grep

Currently when I have to search for complex patterns in code, I typically use a combination of find and grep in the form: find / \( -type f -regextype posix-extended -regex '.*python3.*py' \) -exec grep -EliI '\b__[[:alnum:]]*_\b' {} \; -exec cat…
alpha_989
  • 4,882
  • 2
  • 37
  • 48
3
votes
2 answers

Ag Silver Searcher: output file name when used in while-loop

When using ag (edit: version 0.33.0) in a Bash while loop I can't make it show me any file names: #!/bin/bash cat <<__m | while read mod; do ag --nogroup --filename --ignore=local "^use $mod" ./; done CGI CGI::Push __m Output: use 4.08; use…
MaxHQ
  • 53
  • 1
  • 6
3
votes
1 answer

Ack.vim with ag not using current directory?

I am at the moment trying to figure out vim and craft my own .vimrc. After some research about search-commands and plugins I decided to follow the advice of someone and try out Ack.vim with SilverSearcher/Ag for the actual searches. I encountered…
AvantiC
  • 367
  • 3
  • 17
3
votes
2 answers

ag: silver searcher: ignore multiple formats

with the silver searcher, how can i ignore any files with multiple specific extensions? for example, i've tried: $ ag --ignore '*.js|*.txt' 'foobar' this doesn't work. i don't want a `.agignore' file.
象嘉道
  • 3,657
  • 5
  • 33
  • 49
3
votes
1 answer

What is ag's (silver searcher) analogous option to grep's --line-buffered?

I'd like to use ag as if I would use grep with --line-buffered. Is it possible? If not what other options do I have to mimic such behaviour?
Gabor Marton
  • 2,039
  • 2
  • 22
  • 33
3
votes
1 answer

Is there a way to insert the current search pattern into commandline?

After installing Ag.vim I've had a frequent need to copy a search from * or / into the command line to search across all files in a codebase. Example use case: I find a string of text user_profile_uri and use * to select it. I press : to enter…
Javon Harper
  • 176
  • 7
2
votes
1 answer

Ag / Grep Exact Match Only Search

I am having an issue with using Ag (The Silver Searcher)... In the docs it says to use -Q for exact match, but I don't understand why it does not work for my purposes. If I type something like ag -Q actions or ag -Q 'actions' into my terminal, it…
Lushmoney
  • 412
  • 11
  • 26
2
votes
3 answers

Recursively finding files in list of directories

How do I recursively count files in a list of Linux directories? Example: /dog/ /a.txt /b.txt /c.ipynb /cat/ /d.txt /e.pdf /f.png /g.txt /owl/ /h.txt I want following output: 5 .txt 1 .pynb 1 .pdf 1 .png I tried the following,…
ThinkGeek
  • 4,749
  • 13
  • 44
  • 91
2
votes
1 answer

How to search with case sensitive with ag in MAC?

i want to search with case sensitive, seems "ag -i" should do the job. But when i run it in MAC, seems it's not the case. Anyone has same issues ?
user3552178
  • 2,719
  • 8
  • 40
  • 67
2
votes
2 answers

How to use ag aka the_silver_search to search for directories only?

I like to search for directories only, and the option ag --list-file-types is not helpful with that. The reason to stick to ag is the possibility to pick a file with --path-to-ignore containing patterns to ignore. An equivalent command would be fd…
F. Röder
  • 21
  • 2
2
votes
3 answers

Can ack/ag/grep print function name?

Is it possible to print the function or class name in which a keyword occurs when using ack or ag? This is something I have highly desired for quite some time. I think it would be quite tricky, as different programming languages have different ways…
shivams
  • 923
  • 12
  • 27
2
votes
2 answers

How to escape a PCRE pattern with bash (ag)

Question How do I escape a regex (PCRE) to use in bash (with ag)? Attempts ag (?!.*rib)(?=.*dist)^(\w+)$ # -bash: !.*wib: event not found ag "(?!.*rib)(?=.*dist)^(\w+)$" # -bash: !.*wib: event not found ag '(?!.*rib)(?=.*dist)^(\w+)$' # This does…
Ashley Coolman
  • 11,095
  • 5
  • 59
  • 81
2
votes
1 answer

SilverSearcher - Why can I use `--ignore=PATTERN` when documentation says `--ignore PATTERN` without a equal sign?

I had to ignore multiple directories, so I tried ag --hidden --ignore '.git' --ignore 'plugged' -g "" But this process of narrating --ignore each time I tried to ignore a directory felt needless. So, I tried with bash curly brace completion like in…
3N4N
  • 570
  • 5
  • 21
2
votes
1 answer

How do I ag search into a specific set of folders using the -G option?

How do I ag search into a specific set of folders using the -G option? Here's an example where I use -G routes, but it's picking up another result from another folder, because routes is still in the path. Yet if I try -G ^routes, it doesn't seem…
Jesse Leite
  • 6,581
  • 3
  • 18
  • 17