Find a file containing specific word in Linux

Everyone of us know how to find a line in a file containing particular word in linux, i.e. simply using grep command. (Example: grep [word_to_find] [filename])
But how to find name of the files in particular directory and their sub-directories that contains one specific word using the same grep command.
Below is the simple grep command to do it.

grep -rin ‘[path to search]’ -e ‘[word to search]’

-r refers to recursive
-i refers to ignore case (optional)
-n refers to line number of the file where specific word is found

Leave a Reply

Your email address will not be published. Required fields are marked *