college/Summer-2024/CS-3424/Quizzes/Quiz-2/even-lines-simple.bash

25 lines
444 B
Bash
Raw Normal View History

2024-06-23 04:09:55 -05:00
#!/usr/bin/env bash
set -eEou pipefail
main() {
local input="${1}"
local line_count=0
while read -r line; do
# To satisfy the `set -u` incantation at the top, we have to assign the variable instead of
# a simple ((line_count++))
line_count=$((line_count + 1))
if ((line_count % 2 == 0)); then
printf "%s\n" "$line"
fi
done <"$input"
if ((line_count > 10)); then
printf "big\n"
else
printf "small\n"
fi
}
main "${@}"