Linux Commands Helper
💬 Your AI-powered Linux assistant
grep Command - Search Text Patterns
The grep command is used to search text using patterns. It prints lines that match the specified pattern.
Syntax
grep [options] pattern [file...]
Examples
grep root /etc/passwd
Search for the string "root" in the /etc/passwd file.
grep -i root /etc/passwd
Search case-insensitively for "root" in /etc/passwd.
grep -r pattern /path/to/dir
Recursively search for "pattern" in all files under /path/to/dir.
Notes
- grep supports regular expressions for powerful pattern matching.
- Common options include
-i
(ignore case),-v
(invert match), and-r
(recursive).