grep

Filtrando resultados em arquivos.

Get e-mails:

grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b"

Get valid IP addresses:

grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"

Search for a text in any files of the current dir:

grep -r "MY SEARCH TERM"

Searching for URLs:

grep -Eo '(http|https)://[^/"]+'
grep -v "TERM TO EXCLUDE"

Recursive search only for specific type of files:

# will search for the regex only in html files
# in the current directory recursively
grep --include=\*.html -rE "MY_REGEX" ./

Last updated

Was this helpful?