37 lines
886 B
Awk
Executable File
37 lines
886 B
Awk
Executable File
#!/usr/bin/awk -f
|
|
|
|
#
|
|
# Example of the use of 'switch' in GNU Awk.
|
|
#
|
|
# Should be run against the data file 'file1.txt' included with the second
|
|
# show in the series: http://hackerpublicradio.org/eps/hpr2129/file1.txt
|
|
#
|
|
NR > 1 {
|
|
printf "The %s is classified as: ",$1
|
|
|
|
switch ($1) {
|
|
case "apple":
|
|
print "a fruit, pome"
|
|
break
|
|
case "banana":
|
|
case "grape":
|
|
case "kiwi":
|
|
print "a fruit, berry"
|
|
break
|
|
case "strawberry":
|
|
print "not a true fruit, pseudocarp"
|
|
break
|
|
case "plum":
|
|
print "a fruit, drupe"
|
|
break
|
|
case "pineapple":
|
|
print "a fruit, fused berries (syncarp)"
|
|
break
|
|
case "potato":
|
|
print "a vegetable, tuber"
|
|
break
|
|
default:
|
|
print "[unclassified]"
|
|
}
|
|
}
|