grep does not find a way to hide a folder
The default grep searches all files, including files under Hidden folders.
For example, use the following command to search for Mediabutton strings, which contain files under hidden folders.
GREP-NR Mediabutton *
If you are using SVN-managed code, there is a. svn hidden folder under each folder that contains control information about the version of the code, and it will accumulate over a large amount of the day. If it's just a default search, a lot of search results are in the SVN directory, which is worthless to us, and it can take a lot of time.
The--exclude-dir= parameter of grep is to exclude a directory, which does not contain the directory after the equals sign, so we can use this parameter to remove the. SVN hidden directory.
The use of the--exclude-dir= parameter is as follows:
1. If you had GNU Grep, it should work like this:
---=". SVN" For example: Find all code with "Mediabutton" string in the current directory and subdirectoriesand print line numbers
Grep-nr--exclude-dir= ". SVN" Mediabutton *
Or
GREP-NR--EXCLUDE-DIR=\.SVN Mediabutton *
The directories to be excluded after--exclude-dir= are enclosed in double quotation marks or directly to the directory name, but special characters must be represented by an escape character, such as ". SVN".
2.If happen to is on a Unix System without GNU Grep, try the following:
This is done by using a double-layer "filter" of the pipeline, where the second grep uses the- v option, which is the inverse match , which prints out the mismatched rows
-"Whatever"*| -"\.svn/*"3. If you enter the --exclude-dir= parameter each time, is it slow and error prone, reducing efficiency?
But don't worry, we can add the--exclude-dir= parameter by adding a configuration file ~/.bashrc (this is bash's current user profile) to simplify operations and improve efficiency.
Add the following command at the end of the ~/.BASHRC file:
Export grep_options= "--EXCLUDE-DIR=\.SVN"
then save, execute the source ~/.BASHRC or. ~/.BASHRC to make the changes work.
Then, when searching, execute the following command:
GREP-NR Mediabutton *
This will load the Grep_options option by default, without searching for the. SVN directory.
Note that the Grep_options keyword can not be modified to other, otherwise the system will not be considered to be GREP an option parameter.
Reference:
http://blog.csdn.net/ameyume/article/details/7711420
grep does not find a way to hide a folder