GREP Commands Cheat Sheet
Here is a cli commands cheat sheet for GREP command, you can use this as a quick reminder for basic commands with a brief description for each of the commands.
What is GREP command?
Add some data here
# To search a file for a pattern: grep# To perform a case-insensitive search (with line numbers): grep -in # To recursively grep for string in : grep -R # Read search patterns from a file (one per line): grep -f # Find lines NOT containing pattern: grep -v # Set how many lines to show before (-B) and after (-A) pattern: grep -B 3 -A 2 # To grep with regular expressions: grep "^00" # Match lines starting with 00 grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" # Find IP add # To find all files that match in grep -rnw -e # To exclude grep from your grepped output of ps: # (Add [] to the first letter. Ex: sshd -> [s]shd) ps aux | grep '[h]ttpd' # Colour in red {bash} and keep all other lines ps aux | grep -E --color 'bash|$'
Check out the GREP command documentation .
You can also check our MegaSh cheatsheet tool, that has 150+ searchable linux cheat sheets in one page, so you never forget a command as you work again