For system, network and cloud administrators
The shell is one of the most important parts of a Unix system and that’s why developers and admins around the world rely so much on it. It’s basically a program inside which the user can run commands and create shell scripts. Unix programmers used the shell as a programming environment too. In fact, a lot of the important parts of the Unix system itself are … shell scripts.
In order to be able to delete all Azure managed disks that start with mydisk, for example, you’ll first need to run the Azure Bash shell instead of PowerShell and then type:
az disk list --query "[?starts_with(name,'mydisk')].[name]" | xargs -L1 bash -c 'az disk delete --resource-group yourresourcegroup --name $0 --yes'
In order to delete all Azure storage accounts that start with mystorage, for example, you’ll first need to run a Bash shell instead of PowerShell. Then, type:
az storage account list --query "[?starts_with(name,'mystorage')].[name]" --output tsv | xargs -L1 bash -c 'az storage account delete --name $0 --yes'
In order to delete all resource groups that start with project01, for example, you’ll first need to make sure you’re in a Bash shell and not PowerShell. Then, type:
az group list --query "[?starts_with(name,'project01')].[name]" --output tsv | xargs -L1 bash -c 'az group delete --name $0 --no-wait --yes'
brew install bash-completion
echo "[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion" >> ~/.bash_profile
source ~/.bash_profile