I am searching through a Git repository and would like to include the .git
folder.
grep
does not include this folder if I run
To find only within a certain folder you can use:
ls -al | grep " \."
It is a very simple command to list and pipe to grep.
To search within ONLY all hidden files and directories from your current location:
find . -name ".*" -exec grep -rs search {} \;
ONLY all hidden files:
find . -name ".*" -type f -exec grep -s search {} \;
ONLY all hidden directories:
find . -name ".*" -type d -exec grep -rs search {} \;
To prevent matching .
and ..
which are not hidden files, you can use grep
with ls -A
like in this example:
ls -A | grep "^\."
^\.
states that the first character must be .
The -A
or --almost-all
option excludes the results .
and ..
so that only hidden files and directories are matched.
All the other answers are better. This one might be easy to remember:
find . -type f | xargs grep search
It finds only files (including hidden) and greps each file.