Alex Rivera | Logout

Get a list of running VMs using VBoxManage

Asked 2011-08-15T19:11:11.617
18

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
Edit
Report

1 Answer

18
VBoxManage list runningvms | cut -d '"' -f 2 | while read machine; do
   echo "$machine"
done
answered 2011-08-15T19:18:45.677

Your Answer