What is grep?

QuestionsQuestions8 SkillsProUser Account ManagementAug, 20 2025
0154

grep is a command-line utility in Unix and Unix-like operating systems used for searching plain-text data for lines that match a specified pattern. The name stands for "Global Regular Expression Print."

Key Features:

  • Pattern Matching: It uses regular expressions to define search patterns, allowing for complex searches.
  • Output: By default, grep prints the lines from the input that match the pattern.
  • Options: It has various options to modify its behavior, such as:
    • -i: Ignore case (case-insensitive search).
    • -v: Invert match (show lines that do not match the pattern).
    • -r: Recursively search through directories.

Example:

To search for the word "error" in a file named log.txt, you would use:

grep 'error' log.txt

This command will display all lines in log.txt that contain the word "error".

If you have more questions or need examples, let me know!

0 Comments

no data
Be the first to share your comment!