# Grep & Regex & Find strings

## Grep To find Files and Strings

We can use GREP to find some keywords and files and some special strings

<pre class="language-python"><code class="lang-python">grep -inr password

<strong>i is for case insensitivity
</strong>n is for line number
r is for recursively

this command will recursively search for the keyword password 
</code></pre>

## Grep to find strings using Regex

lets say we have a file with a certain line

<figure><img src="https://3420091786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1ZUO45eHY8aMCLJ7OiN%2Fuploads%2FY3snb6gwg0PkeOxR2Lgo%2Fimage.png?alt=media&#x26;token=11c41c1e-56c8-4cfd-a673-36c7c4ae04a6" alt=""><figcaption></figcaption></figure>

now i need to find in how many files this line exists, so i can use regex with grep

```python
grep -rnw $(pwd) -e "^.*user_location.*public.*" --color


$(pwd)- means your current working directory in which you want to find
        otherwise give the complete path of the directory here
        
this command will find you the all files having above line 
```

## Egrep to do Advanced Regex

We can use egrep for more advanced regular expressions, below is the egrep command with more advacned regex which finds for $addslahses keyword and whatever is after that.

```
egrep '\$addslashes.*=.*' $(pwd) -r --color
```

## Find Command

```
find / -iname "*.html"
```
