advent-of-code/2023/day1/day1.sh

7 lines
173 B
Bash
Raw Normal View History

#!/bin/sh
tr -d a-z < $1 | grep -o '^.' > first
tr -d a-z < $1 | grep -o '.$' > last
paste -d '\0' first last | \
awk 'BEGIN { sum = 0 } { sum += $0 } END { print sum }'