Reputation: 7327
I want to take the following "Names" from this command and put them in an array for a bash script, any ideas on the best way to do this?
$ virsh -r -c qemu:///system list --all
Id Name State
----------------------------------------------------
3 KVM_Win7-KVM running
EDIT:
The final result was this:
declare -a kvm_list=( $(virsh -r -c qemu:///system list --all --name) )
Upvotes: 1
Views: 349
Reputation: 311703
First consider using the --name
option to virsh --list
, so you end up with:
virsh -r -c qemu:///system list --all --name
And then reading output of command into array in bash
Upvotes: 2