Created
June 2, 2013 15:54
-
-
Save Ragnarokkr/5693919 to your computer and use it in GitHub Desktop.
Simple function to search for a valid VirtualBox VM and return its UUID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Searches for a currently available VirtualBox VM and returns its UUID. | |
# | |
# Code by Marco Trulla a.k.a. Ragnarøkkr | |
# http://marcotrulla.it/ | |
# http://github.com/Ragnarokkr | |
# | |
# Params: | |
# $1 => the regex pattern to search for in currently available virtual machines | |
# (case sensitive). | |
# | |
# Returns: | |
# the VM's UUID or nothing. | |
# | |
# Example: | |
# | |
# VBoxHeadless -s `vbox-query-uuid "Ubuntu Server 13.04"` | |
vbox-query-uuid () { | |
local uuid=$(VBoxManage list vms | egrep "$1" | sed -e 's/.*{\(.*\)}.*/\1/g') | |
echo $uuid | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment