grep is a command-line utility used to search for specific patterns within text files. Here's how it works:
- Input:
greptakes input from files or standard input (stdin). - Pattern Matching: It searches for lines that match a specified pattern, which can be a simple string or a more complex regular expression.
- Output: It outputs the lines that contain the matching pattern.
Basic Syntax
grep [options] pattern [file...]
Common Options
-i: Ignore case (case-insensitive search).-v: Invert match (show lines that do not match the pattern).-r: Recursively search directories.-n: Show line numbers with output lines.
Example
To search for the word "example" in a file named file.txt:
grep 'example' file.txt
This command will display all lines in file.txt that contain the word "example".
If you have more specific questions about grep or need examples, let me know!
