Interview Prep/Real-World Interview/awk, sed, grep and jq one-liners

Extract all unique email addresses from a file.

BeginnerHands-onawk, sed, grep and jq one-liners
Answer
grep -Eoi '[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}' file.txt | sort -fu

Key trick → -o prints only the matched part, not the whole line. sort -fu de-duplicates without caring about case.

All Real-World Interview questions Roadmap: Interview readiness

More on awk, sed, grep and jq one-liners