Script to add books to my books.md file

I have a file, called books.md that populates the books section of the website. In the past, whenever I wanted to add a book to the wishlist section of that file, I had to open the file, work with messy parenthesis, add the name of the book, the link to the shop and the author’s name. Finally, I had to close the file. Too cumbersome. I have now created a script to remove some of that boring and messy work.

#!/bin/bash

# I want to add a book in the form "- [_name_of_the_book_](_link_to_the_store_) by _author_" to the appropriate section in the file of read and to-read books.

filename=books.md

read -p "Name of the book: " book_name
read -p "Link to shop: " shop_link
read -p "Author: " author

linenumber=$(sed -n '/## To Read (Wishlist)/=' $filename)
linenumber=$((linenumber+4))

string_to_add="- [$book_name]($shop_link) by $author;"

sed -i "$linenumber i $string_to_add" $filename

First, it asks for the name of the book, the link to the shop and the author’s name. Then, it searches for the “Wishlist” aka “To Read” section of the file. Then it adds a link with the appropriate markdown form for linking and listing items.

As an example, after writing the name of the book, shop link and author’s name, the line ‘- [Super Thinking](https://www.kobo.com/de/en/ebook/super-thinking-1) by Gabriel Weinberg;" is added to the appropriate section of the file. See those annoying parenthesis? Ya…

The next iteration of this script will probably just take “book_name,link,author” and do its thing. But adding a comma or pressing enter results in the same number of keypresses, so there is no obvious need to do it this way.