Logseq as Shopping List & Cleanup old grocery records

My current workflow for shopping list is: [1]

  1. In today’s journal page, write LATER meat #shopping/grocery
  2. When I’m in the shop, check the page shopping/grocery

However, the old grocery items, marked as DONE will still appear on this page. I created a bash script to clean up these old items manually.
(It works fine in WSL. It should work fine in Linux/mac)

BACKUP_DIR=grocery_cleanup_backup-`date '+%Y-%m-%d-%H-%M%S'`

mkdir $BACKUP_DIR

for entry in $(ls journals)
do
	egrep -v 'DONE.+shopping/grocery' journals/$entry > temporary.txt
	mv journals/$entry $BACKUP_DIR
	mv temporary.txt journals/$entry
done

[1]: Someone shared it with me. I’m sorry that I can’t find the discussion and provide credit for this one.