Search code examples
ag

silver searcher fail for certain files


I'm having trouble recently using silver searcher.

There are 2 files in a directory containing same content:


A.cpp:

This is a cpp file


B.cpp:

This is a cpp file


However, $ ag cpp returns the result of B.cpp, not that of A.cpp:

B.cpp

1:This is a cpp file

How do I deal with that?

Here is the ag command man page


Solution

  • I guess A.cpp has been ignored.

    Check your .gitignore and .ignore, etc..

    Or you simply search all files with $ ag cpp -u.

    See more detail by

    $ ag | ag "unrestricted"

    -u --unrestricted Search all files (ignore .ignore, .gitignore, etc.; searches binary and hidden files as well)