forked from FreedomBen/awk-hack-the-planet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
18.awk
33 lines (30 loc) · 772 Bytes
/
18.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function getName(first, last) {
return sprintf("%s %s", $1, $2)
}
BEGIN {
lowestYear = 9999
lowestMonth = 99
lowestDay = 99
name = ""
}
$0 !~ /HourlyWage/ {
split($7, date, "/")
if (date[1] < lowestYear) {
lowestYear = date[1]
lowestMonth = date[2]
lowestDay = date[3]
name = getName($1, $2)
}
if (date[1] == lowestYear && date[2] < lowestMonth) {
lowestMonth = date[2]
lowestDay = date[3]
name = getName($1, $2)
}
if (date[1] == lowestYear && date[2] == lowestMonth && date[3] < lowestDay) {
lowestDay = date[3]
name = getName($1, $2)
}
}
END {
printf "%s was the first employee hired on %d/%d/%d\n", name, lowestYear, lowestMonth, lowestDay
}