Skip to content

Instantly share code, notes, and snippets.

@iknowkungfoo
Last active December 13, 2018 22:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iknowkungfoo/7a349c537be48855797811f8db149f41 to your computer and use it in GitHub Desktop.
Save iknowkungfoo/7a349c537be48855797811f8db149f41 to your computer and use it in GitHub Desktop.
This will output a list of all emails in a specific file or in a folder.

File

Find in a single file:

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

Folder

When checking in folders, the output will list the matches as filename:email for every match in a file.

The option --exclude-dir requires just the name of the folder to exclude, not the whole file path.

Find all in a folder:

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

File all in a folder, excluding certain folders:

grep -E -o -r --exclude-dir=folder1 --exclude-dir=folder2 "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" wwwroot/ 

Citations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment