Back to problems
COMP2041
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.
Samples
stdin
COMP1511|3360379|Costner, Kevin Augustus |3978/1|M COMP1511|3364562|Carey, Mary |3711/1|M COMP3311|3383025|Thorpe, Ian Augustus |3978/3|M COMP4920|3860448|Steenburgen, Mary Nell |3978/3|F COMP1521|3360582|Neeson, Liam |3711/2|M COMP3411|3863711|Klum, Heidi June Anne |3978/3|F COMP3141|3383025|Thorpe, Ian Augustus |3978/3|M COMP3891|3863711|Klum, Heidi June Anne |3978/3|F COMP3331|3383025|Thorpe, Ian Augustus |3978/3|M COMP2041|3860448|Steenburgen, Mary Nell |3978/3|F COMP2041|3360582|Neeson, Liam |3711/2|M COMP3311|3711611|Klum, Mary |3978/3|F COMP3311|3371161|Thorpe, Ian Fredrick |3711/3|M COMP3331|5122456|Wang, Wei |3978/2|M COMP3331|5456732|Wang, Wei |3648/3|M COMP4920|5456732|Wang, Wei |3648/3|M
expected
Carey Costner Neeson Thorpe Wang
shell
14