← Back to problems
UNSW COMP2041 · medium

21T2 Q2 — Male surnames (shell pipeline)

Given student enrolment data on stdin in the format Course|StudentID|Name|Plan|Gender (Name is surname(s), given-name(s), Gender is M/F), write a single shell pipeline that prints the surnames of male students, each surname once, in alphabetical order. Input is unordered.

Example:

$ ./prog < enrollments.txt
Carey
Costner
Neeson
Thorpe
Wang

POSIX shell only (#!/bin/dash); standard UNIX filters; no awk, Perl, C or Python. From COMP2041/9044 21T2 Final.