>_ IzzyLab

Hands-on task

This task is step 8 of the course “Text in the terminal: grep, sed, awk”

Contacts from meeting minutes

easy~3 min

/root/meeting.txt holds meeting minutes; the participants' e-mail addresses appear in the text — in angle brackets, in parentheses, separated by commas. Extract all addresses to /root/contacts.txt: one per line, just the address, without brackets or punctuation.

What you'll practise:
  • grep -oE
  • regular expressions
  • character classes
  • email

Topic breakdown

When you need pieces inside lines rather than whole lines, grep is switched to "only matching" mode: each match found is printed on a new line. An email splits into parts — the local name, @, the domain and the zone — and each part is described by its own class of allowed characters. The surrounding brackets and commas aren't in those classes, so the match stops at the address boundary by itself. A dot inside a class [...] is literal, while outside it means "any character" — so it gets escaped.

What's checked

  1. all addresses found
  2. addresses extracted whole, without brackets or commas

What it looks like