Wrote A Script To Delete All Resource Groups In An Azure Subscription

In the Azure portal you can’t select multiple resource groups for deletion. I have a sponsored subscription to play around in which I sometimes wish to clean completely. I wrote this script to delete all resource groups using bash. #!/bin/bash # script to delete all resource groups in a subscription using Azure CLI # get the current subscription name to confirm subscription=$(az account show --query name -o tsv) echo "Use this script with caution!" echo "You are about to delete all resource groups in the subscription: $subscription" # prompt for confirmation read -p "Are you sure? (y/n) " will_delete if [[ $will_delete == [Yy]* ]]; then echo "Deleting resource groups..." groups=$(az group list --query "[].name" -o tsv) # Loop through each group name and delete it for group in $groups; do az group delete --name "$group" --yes --no-wait done echo "All resource groups have been deleted." exit 0 fi echo "Exiting without deleting any resource groups." echo "Probably wise." Links: 202307081507 ...

July 8, 2023 · Mischa van den Burg

Video: How I Write & Publish My Blog Using Neovim & Hugo From The Command Line

I show my workflow to publish my Hugo blog from the command line using neovim and bash Links: 202305091705

May 9, 2023 · Mischa van den Burg

Generating Markdown Headings with YYYY-MM-DD Date Format Using Bash

A couple of weeks ago I created a simple bash script to generate a date in format YYY-MM-DD to use with the magic !! wands in vim. Just now I wanted to expand this with being able to create a markdown header with this date. #!/bin/bash # Gendate generates the date in YYY-MM-DD format # Can be called with arguments h and number to generate a markdown heading # For example: 'gendate h 3' will generate '### 2023-03-29' header="" date=$(date +"%Y-%m-%d") if [[ $# -gt 0 ]]; then # handling wrong arguments if [[ $# -eq 1 || "$1" != "h" ]]; then echo "Usage: gendate h 2 to generate with markdown heading ##" exit 1 fi # format markdown heading if arguments h, n are given if [[ $# -eq 2 ]]; then for i in $(seq 1 $2); do header+="#" done header+=" "$date echo "$header" exit 1 fi fi # if no arguments given, generate the date echo "$date" Links: 202304011104 ...

April 1, 2023 · Mischa van den Burg

Using parameter expansion as search and replace

Last modified: 2023-01-10 In this evening’s studies I came across this bash script in a tutorial by Rob Muhlenstein: !#/bin/bash echo -e ${PATH//:/\\n} I could not make heads or tails of all these slashes and curly braces, since the output clearly indicated that search and replacement was being performed. I’m used to the sed / vim syntax: s/foo/bar After some research I learned that ‘//’ is a global search and replace syntax of several text processing programs. It is known as parameter expansion in bash. ...

January 10, 2023 · Mischa van den Burg

Back to Bas(h)ics: leaving zsh for now

I’ve used zsh for nearly two years now. I have a custom setup with autocompletion and a good looking prompt. Recently I’ve been diving deeper into bash scripting, following tutorials by rwxrob. He emphasizes all the time that it is much better to stick to bash instead of zsh. Advantages of using bash: the default Linux shell available on any Linux system full documentation available anywhere at all times with man bash free software less dependent on external plugins and configurations more portable practice by working on the command line The fact that working on the commandline is already coding convinced me to leave my beloved customized prompt behind (for now) and go back to the basics. ...

January 8, 2023 · Mischa van den Burg