bookmarks/fix_missing_dates.sh

15 lines
570 B
Bash
Raw Permalink Normal View History

2018-09-28 10:08:06 +00:00
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
2018-09-08 09:40:38 +00:00
current=$(date "+%Y")
for ((year=1900; year<=current; year=year+1))
do
grep "/$year/" "$BASEDIR/README.md" | grep -v "($year)" | grep -v " - (" | while read -r line
do
echo "$line"
replace=$(echo "$line" | sed "s/) - /) - ($year) /g" | sed -e "s#\*#\\\*#g" | sed -e "s#\[#\\\[#g" | sed -e "s#\]#\\\]#g" | sed -e "s#/#\\\/#g")
orig=$(echo "$line" | sed -e "s#/#\\\/#g" | sed -e "s#\*#\\\*#g" | sed -e "s#\[#\\\[#g" | sed -e "s#\]#\\\]#g" )
sed -i.bak "s;$orig;$replace;g" "$BASEDIR/README.md"
done
2018-09-08 09:40:38 +00:00
done