Advent-of-Code/day1/solution-part1.sh
Jonathan Hodgson f6a7e1dbfe Day 1
2021-12-01 22:03:50 +00:00

17 lines
252 B
Bash
Executable file

#!/usr/bin/env bash
# Give file as option 1
file="$1"
increasing=0
last=99999999
while read line; do
if [ "$line" -gt "$last" ]; then
increasing="$(( increasing + 1 ))"
fi
last="$line"
done < <(cat "$file")
echo "$increasing were increasing"