12 lines
331 B
Bash
Executable File
12 lines
331 B
Bash
Executable File
#!/bin/sh
|
|
|
|
printf '['
|
|
delimiter=""
|
|
virsh list --all | tail -n +3 | while read -r line; do
|
|
capsul_id="$(echo "$line" | awk '{ print $2 }')"
|
|
capsul_state="$(echo "$line" | sed -E 's/^ *[0-9-]+ +[^ ]+ +//')"
|
|
printf '%s\n {"id":"%s", "state":"%s"}' "$delimiter" "$capsul_id" "$capsul_state"
|
|
delimiter=","
|
|
done
|
|
printf '\n]\n'
|