1

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) )
Mike Q
  • 6,716
  • 5
  • 55
  • 62

1 Answers1

2

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

Community
  • 1
  • 1
larsks
  • 277,717
  • 41
  • 399
  • 399