script listing VirtualBox machines and RAM usage
!/bin/bash
script listing VirtualBox machines and their RAM and State
for name in $(VBoxManage list vms | grep \" | awk '{print $1}' | tr -d '"')
do echo $name VBoxManage showvminfo $name | grep -E 'Memory|State|VRDP' done
exit 0
SCRIPT EXPLAINED
VBoxManage list vms //lists all of the virtual machines the current user has defined | //pipe operator passes the output to the next program grep \" //only finds lines with a " | awk '{print $1}' //only displays the first column of data (white space delimited) | tr -d '"' //removes the quote character, e.g. "vmname" now becomes vmname //could be character replacement: tr '"' '-'
FOR LOOP
for ((i=1; i<5; i++))
do
echo $i
done
echo $name //display the name of each item from the list generated above VBoxManage showvminfo $name //lists the info for each VirtualBox virtual machine (by name variable) | grep -E 'Memory|State|VRDP' //Only list the info from lines contained Memory or State or VRDP