Skip to content

Instantly share code, notes, and snippets.

@brahimmachkouri
Last active June 24, 2017 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brahimmachkouri/d6875a7c988d366ba3802ed36519ead5 to your computer and use it in GitHub Desktop.
Save brahimmachkouri/d6875a7c988d366ba3802ed36519ead5 to your computer and use it in GitHub Desktop.
This script displays vagrant index_uuid for each VM created with Vagrant (macOS)
#!/bin/bash
vms=$(vagrant global-status | awk -F " " '{ print $5 }' | grep Users)
for vm in $vms
do
if [ -d "$vm" ]; then
cat $vm/.vagrant/machines/default/virtualbox/index_uuid
echo " $vm"
fi
done
@brahimmachkouri
Copy link
Author

It is useful when you want to remove a vagrant box, but this box is still used by a VM. In this case, Vagrant informs you by displaying the VM uuid, but not its name. This script displays the corresponding VM name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment