A Comprehensive list of Grep and its arguements

Posted 2 years ago

Grep if you don’t know is a way of searching based on a given pattern.

Grep basics

To search type grep followed by some parameters (such as -R to recursively search) then the input you want to search.

The below code will recursively loop the server and ignore all case for the word memory_limit. The * signals the fact you want to look all over the server however you can specify a specific path.

grep -Ri "memory_limit" *

This will achieve the same as above but instead of searching the server it will search just within the folder error_logs (and any subsequent folders)

grep -Ri "memory_limit" /home/domain/error_logs/

Table of Grep parameters and what they mean

Ignore the case in the pattern, in the above above example it will match memory_limit and Memory_limit

-R, -r,—recursive:
Recursively look through each directory (folder)