diff --git a/reading04/Makefile b/reading04/Makefile new file mode 100644 index 0000000..3d9f567 --- /dev/null +++ b/reading04/Makefile @@ -0,0 +1,11 @@ +test: + @$(MAKE) -sk test-all + +test-all: test-scripts test-filters + +test-scripts: + curl -sLO https://www3.nd.edu/~pbui/teaching/cse.20289.sp25/static/txt/reading04/test_filters.sh + chmod +x test_filters.sh + +test-filters: + ./test_filters.sh diff --git a/reading04/filters.sh b/reading04/filters.sh new file mode 100644 index 0000000..523032a --- /dev/null +++ b/reading04/filters.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +q1_answer() { + # TODO: List only the names of the turtles in sorted order. + curl -sL https://yld.me/raw/hoUY | cut -d: -f1 | sort +} + +q2_answer() { + # TODO: List only the colors of the turtles in all capitals. + curl -sL https://yld.me/raw/hoUY | curl -sL https://yld.me/raw/hoUY | cut -d: -f3 | tr [a-z] [A-Z] +} + +q3_answer() { + # TODO: Replace all weapons with plowshares. + curl -sL https://yld.me/raw/hoUY | sed 's/:.*:/:plowshare:/' +} + +q4_answer() { + # TODO: List only the turtles whose names end in lo. + curl -sL https://yld.me/raw/hoUY | cut -d: -f1 | grep -E '*lo$' +} + +q5_answer() { + # TODO: List only the turtles with names that have two consecutive vowels. + curl -sL https://yld.me/raw/hoUY | cut -d: -f1 | grep -E '[aeiou]{2}' +} + +q6_answer() { + # TODO: Count how many colors don't begin with a vowel + curl -sL https://yld.me/raw/hoUY | cut -d: -f3 | grep -E '^[^aeiou]' | wc -l +} + +q7_answer() { + # TODO: List only the turtles names whose name ends with a vowel and whose + # weapon ends with a vowel. + curl -sL https://yld.me/raw/hoUY | grep -E '^[^:]+[aeiou]:[^:]+[aeiou]:' | cut -d: -f1 +} + +q8_answer() { + # TODO: List only the colors of the turtles whose name has two of the same + # consecutive letter (i.e. aa, bb, etc.) + curl -sL https://yld.me/raw/hoUY | grep -E '^[^:]*([a-zA-Z])\1[^:]*:' | cut -d: -f3 +}