[Linux command] Find a word in a repository with grep

It’s not always easy to remember the name of file which contains exactly what we want to search.
In linux, we can search without knowing the name of the file with the command grep, and of course we should specify a path.

Syntax :

grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]

Example :
Search “Hello world” in my home/test/grep directory :
(-R means Recursive)

grep -R "Hello world" ~/test/grep/


Another example :
(-h means not display the files names)

grep -R -h "Hello world" ~/test/grep/



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s