How can I grep hidden files?

前端 未结 10 1285
北荒
北荒 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

    Perhaps you will prefer to combine "grep" with the "find" command for a complete solution like:

    find . -exec grep -Hn search {} \;
    

    This command will search inside hidden files or directories for string "search" and list any files with a coincidence with this output format:

    File path:Line number:line with coincidence

    ./foo/bar:42:search line
    ./foo/.bar:42:search line
    ./.foo/bar:42:search line
    ./.foo/.bar:42:search line
    

提交回复
热议问题