capsul-flask/capsulflask/shell_scripts/virsh-list.sh

12 lines
331 B
Bash
Raw Normal View History

#!/bin/sh
printf '['
delimiter=""
2021-12-08 18:57:22 +00:00
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'