Where . is the directory where you are at the moment and * is a wildcard.
Oh and you can also combine these. Example:
locate {something}|grep {some_part_of_something}|more
If I recall correctly: locate is the fastest one (assuming your database is up to date) and find is the slowest one. And grep is the most complex but also the most versatile one of these since you can use regexes.
You can use grep to list the files containing word in the given directory:
grep -Ril word directory
Here:
* -R recursively search files in sub-directories.
* -i ignore text case
* -l show file names instead of file contents portions. (note: -L shows file names that do not contain the word).
willis@Cow:~$ grep --help
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
PATTERN is, by default, a basic regular expression (BRE).
Example: grep -i 'hello world' menu.h main.c
With command line you have several options. The 3 I use the most are...
locate {part_of_word}
This assumes your locate-database is up to date but you can update this manually with:
sudo updatedb
grep
as explained by dr_willis. One remark:-R
aftergrep
also searched within directories. Example:find . -name '*{part_of_word}*' -print
Where
.
is the directory where you are at the moment and*
is a wildcard.Oh and you can also combine these. Example:
locate {something}|grep {some_part_of_something}|more
If I recall correctly:
locate
is the fastest one (assuming your database is up to date) andfind
is the slowest one. Andgrep
is the most complex but also the most versatile one of these since you can use regexes.grep -R "what" "where"
example:
grep -R hello /home
You can use
grep
to list the files containingword
in the givendirectory
:Here:
*
-R
recursively search files in sub-directories.*
-i
ignore text case*
-l
show file names instead of file contents portions. (note:-L
shows file names that do not contain the word).use
man grep
to get all the optionsThe grep command is commonly used for this.
grep PATTERN filename
and grep can do some very complex searching.