In this article I will show how to find text in a file in Linux using grep command.
Grep searches for patterns in each file. Patterns is one or patterns separated by newline characters, and grep prints each line that matches a pattern.
$ grep -rw PATH -e PATTERN
-r is recursive
-w only matches the whole words
PATH where search
PATTERN what you serach
-i ignore case
Find Text in File Example
For example, we want to find in which file there is a text184.108.40.206.
$ grep -rw /etc/ -e 220.127.116.11
So grep found the file with name /etc/text_file.txt
You just learn how to find text in a file in Linux using grep command.
Grep is a powerful tool with many features. Тo learn more about the grep command, read the official documentation on grep man pages.