How can I grep hidden files?

前端 未结 10 1278
北荒
北荒 2020-12-07 14:27

I am searching through a Git repository and would like to include the .git folder.

grep does not include this folder if I run



        
10条回答
  •  甜味超标
    2020-12-07 14:59

    Please refer to the solution at the end of this post as a better alternative to what you're doing.

    You can explicitly include hidden files (a directory is also a file).

    grep -r search * .*
    

    The * will match all files except hidden ones and .* will match only hidden files. However this will fail if there are either no non-hidden files or no hidden files in a given directory. You could of course explicitly add .git instead of .*.

    However, if you simply want to search in a given directory, do it like this:

    grep -r search .
    

    The . will match the current path, which will include both non-hidden and hidden files.

提交回复
热议问题