What is the basic usage of the grep command?

The basic usage of the grep command is to search for a specified pattern within a file or input. The general syntax is:

grep 'pattern' filename

Components:

  • pattern: The string or regular expression you want to search for.
  • filename: The name of the file in which you want to search.

Example:

To search for the word "example" in a file named document.txt, you would run:

grep 'example' document.txt

This command will display all lines in document.txt that contain the word "example".

0 Comments

no data
Be the first to share your comment!