AdventOfCode2023/make_readme.sh

16 lines
665 B
Bash
Raw Normal View History

2023-12-06 12:15:51 +01:00
#!/bin/bash
table="| Day | Language | Execuction time | Comment |\n"
2023-12-06 12:16:40 +01:00
table+="|:---:|:---:| ---:| --- |\n"
2023-12-06 12:15:51 +01:00
for day in $(seq -f "%02g" 1 25); do
[[ ! -d "$day" ]] && continue
# echo $day
2023-12-08 13:52:28 +01:00
lang=$(grep -E "Today's language:" $day/README.md | sed -r 's/.*\*\*(.+)\*\*.*/\1/')
exectime=$(grep -E "Execution time:" $day/README.md | sed -r 's/.*\*\*(.+)\*\*.*/\1/')
2023-12-06 12:15:51 +01:00
comment=$(grep -E "<!-- .* -->" $day/README.md | head -1 | sed -r 's/.*<!-- *(.*) *-->.*/\1/')
2023-12-08 13:52:28 +01:00
table+="| [$day]($day) | $lang | $exectime | $comment |\n"
2023-12-06 12:15:51 +01:00
done
# remove table from readme
sed -i '/<!-- table begin -->/q' README.md
echo -e $table | column -t -s '|' -o '|' >> README.md