问题描述
我正在通过Git存储库进行搜索,并希望包含 .git 文件夹。
grep 如果我运行
grep -r search * $,则不包含此文件夹b $ b
什么是grep命令来包含这个文件夹?
您可以显式包含隐藏文件(目录也是文件)。
grep -r搜寻*。*
* 会匹配除隐藏文件和。* 以外的所有文件只会匹配隐藏文件。但是,如果给定目录中没有非隐藏文件或没有隐藏文件,则这将失败。您当然可以明确地添加 .git 而不是。* 。
然而,如果您只是想在给定的目录中搜索,请这样做:
grep -r search 。
。会匹配当前路径,其中将包括非隐藏和隐藏文件。
I am searching through a Git repository and would like to include the .git folder.
grep does not include this folder if I run
grep -r search *
What would be a grep command to include this folder?
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.
这篇关于我怎样才能grep隐藏的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!