I want to loop through my running VM’s and return only what is between quotes.
So this command:
VBoxManage list runningvms
returns:
"UbuntuServer" {7ef01f8d-a7d5-4405-af42-94d85f999dff}
And I only want it to return:
UbuntuServer
This is what i have so far (fail):
#!/bin/bash
for machine in `cat VBoxManage list runningvms`; do
echo "$machine"
done
exit
Warning: all of this is is risky if your VM names have shell glob characters in them, or contain spaces.
You can do something like this if there is only one running VM:
Alternative with bash arrays (same condition):
If that program returns more than one line, a more classic approach would be: