Extract Email Addresses from Text File Using RegEx
Beginner Mode
Start your terminal to use beginner mode.
Scenario
A log file contains various text entries with email addresses scattered throughout. You need to extract all unique email addresses for further processing.
Task
Write a Python script at /home/interview/extract_emails.py that reads /home/interview/logs.txt, uses regular expressions to extract all email addresses, removes duplicates, and saves the unique emails to /home/interview/emails.txt (one email per line).
Example
Expected output format in /home/interview/emails.txt:
[email protected]
[email protected]
[email protected]
...
Terminal requires a larger screen
Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.
Linux Terminal Environment
Write and execute your solution in the terminal below.
Track
| Question | Difficulty | Company | Access |
|---|
Need more practice in this area? Explore more questions →
GitLab