Grep Command in Linux/Unix

Photo by Lukas on Unsplash

Grep Command in Linux/Unix

Table of contents

No heading

No headings in the article.

In Linux or Unix grep is a command which comes pre-installed with the system. if it is not present in your system you can install this by running the below command in your terminal.

$ sudo apt-get install grep

It is widely used command in day to day tasks. This command is used to search a regular expression or string in a text file. Grep stands for global regular expression print.

Syntax:

$ grep "string" file name

If you wish to search something across current directory and inside all the sub- directories you can use -r flag with this command to search recursively.

Syntax:

$ grep -r "string-name" *