我想遍历正在运行的虚拟机并只返回引号之间的内容。
所以这个命令:
VBoxManage list runningvms
返回:
"UbuntuServer" {7ef01f8d-a7d5-4405-af42-94d85f999dff}
我只希望它返回:
UbuntuServer
这是我目前所拥有的(失败):
#!/bin/bash
for machine in `cat VBoxManage list runningvms`; do
echo "$machine"
done
exit
最佳答案
VBoxManage list runningvms | cut -d '"' -f 2 | while read machine; do
echo "$machine"
done
关于bash - 使用 VBoxManage 获取正在运行的虚拟机列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7069482/