grep to search for file content or rpm -qa output

In order to search a specific directory (path_to_directory) and all its subdirectories (-r for recursive) for files that contain a specific text string, use the following command:

grep -r "textstring" path_to_directory

Also very useful is to pipe the output of another process into grep. E.g. you want to know whether a specific rpm package is installed on your system, but you don't remember the exact name. Thus you cannot use the "rpm -q packagename". In that cast you can ask rpm for all installed packages (rpm -qa) and then pipe this output to grep and let grep look for a substring from the packagename that you do remember:

rpm -qa | grep substring

E.g. when the package modutils-2.4.22-8 is installed you have to ask rpm:

rpm -q modutils OR rpm -q modutils-2.4.22

in order to get an answer. The request rpm -q modutils-2.4 would be: The package modutils-2.4 is not installed. Thus if you don't know the exact name of the package, it is a safe bet to grep the rpm output for something you remember exactly.