Grep Essentials
Match all lines containing "search pattern" in any case (lowercase/uppercase).
-> grep -i "search pattern"
Match all lines containing "search pattern" in any case (lowercase/uppercase) in a particular file/folder.
-> grep -i "search pattern" /path/to/file/or/folder
Match all lines containing "search pattern" in any case (lowercase/uppercase) in multiple files and folders simultaneously.
-> grep -i "search pattern" /path/to/first/file /path/to/folder /path/to/other/dest
-c : Prints count of files
-i : Ignores case (lowercase/uppercase)
-l : Displays only list of files
-n : Display line numbers & matched lines
-v : Prints line which do not match the pattern
-w : Match whole word
Count the number of matches for a pattern
-> grep -c "pattern"
Display line number of the matches
-> grep -n "pattern"
Grep in compressed files.
-> zgrep "pattern" file.gz
Find files modified in the last 5 minutes with
-> find . -type f -mmin -5
Last updated