The grep command-line utility is used for searching plain-text data sets for lines that match a regular expression. It is generally used in collaboration with other Linux commands, such as ls, cat, etc., to provide powerful search functionality in files, consoles, IO streams, etc.
Usage
# Search a match string in a filegrep "test" test_file.txt# Recursively search all the files and in the sub-directorygrep -r "test" /some/tmp/dir/*# Get the lines that do not start with a vowel, along with line numbersgrep -v -n -e "^[aeiouAEIOU].*" test_file.txt# Case-insensitive search with 2 lines above and below to display in all the files in the current working directory.grep -i -A 2 -B 2 "test" *# Get all the details for the wired ethernet network interface\\ifconfig | grep -A 4 ens*# Get all the Java processes running.ps aux | grep java