The GREP Command – Complete Guide

GREP is a Unix/Linux command used to search text for patterns using regular expressions. It prints only the lines that match.

grep "pattern" file
Examples:
grep "error" log.txt
grep -i "error" log.txt
grep -n "main" source.c

  • -i → ignore case
  • -r → recursive
  • -n → line numbers
  • -c → count
  • -v → invert match
  • -w → whole word

grep "^root" /etc/passwd
grep "[0-9]\{3\}" file
grep -E "error|fail|panic" log.txt

Find failed SSH logins:
grep "Failed password" /var/log/auth.log
Find function references:
grep -r "initDatabase" src/

• Insanely fast (written in C)
• Handles massive files
• Full regex engine
• Always installed
• Foundation of shell pipelines

grep is the backbone of Unix search.
Quality, Reliability & Service
Thank You For Visiting
Brooks Computing Systems - Jacksonville
Visit https://bcs.archman.us