I'm doing ag "active_record" ., but I want to only care about .rb files.

How do I limit what file types it searches on the command line?

1 Answer 1



ag active_record --ruby

Also you can use:

ag --list-file-types to list the supported file types

Otherwise you can limit by extension (also for unknown filetypes) by providing a regex as follows:

ag -G'\.rb$' active_record

Edited due to correction by bobbaluba

  • This doesn't work for me. I think it should be ag active_record --ruby.
    – vise
    Oct 11, 2017 at 10:34
  • 3
    It's -G, not -g.
    – bobbaluba
    Feb 15, 2018 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.