Great, now it works. Now, I want you to work through another script.
Now, I want a script that does that monthly. On the 1st day of each month.
It creates the file Month.md in the very same fashion. If there’s a file, and it has a front matter, do nothing. If there’s no file or a file without front matter, create it with the front matter.
Then, after the front matter, I want the previous month to be listed with the help of cal utility. You can put it into a code block (markdown syntax).
Then find the previous month’s Month.md (would be located in the 1st day of the previous month too). And copy the content that follows the # This Month header.
Then insert this month with the help of cal utility. You can put it into a code block (markdown syntax).
Then insert the content of a template file (specified in the script), that goes right after the front matter (ends with +++
and an empty line).
Then take five previous Week.md files (chronological order, starting with the oldest one). Remember, each Week.md files is located in the *-Sun
directory, so try to make it as simple as possible, possibly with the help of date utility. I think this would do:
for i in {5..1}; do
DAY_DIR=$(date -d "this sunday -$i weeks" +"%Y/%m-%d-%a")