More actions
Created page with "The following <code>bash</code> command will list all virsh guests in json. echo "[ $(virsh list --all|grep -Ev 'Id|----'|awk '{print "{ \"id\": \""$1"\", \"name\": \""$2"\", \"state\": \""$3 $4"\"}," }'|head -n -1) {} ]"|jq -r Output example: <pre> [ { "id": "38", "name": "Mac", "state": "running" }, { "id": "39", "name": "Dennis", "state": "running" }, { "id": "40", "name": "Charlie", "state": "running" }, ... </pre>" |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
The following <code>bash</code> command will list all virsh guests in json. | The following <code>bash</code> command will list all virsh guests in json. | ||
<syntaxhighlight lang="bash"> | |||
echo "[ $(virsh list --all|grep -Ev 'Id|----'|awk '{print "{ \"id\": \""$1"\", \"name\": \""$2"\", \"state\": \""$3 $4"\"}," }'|head -n -1) {} ]"|jq -r | |||
</syntaxhighlight> | |||
Output example: | Output example: | ||
< | <syntaxhighlight lang="json" line> | ||
[ | [ | ||
{ | { | ||
| Line 23: | Line 25: | ||
}, | }, | ||
... | ... | ||
</ | </syntaxhighlight> | ||
# TODO: Come back and redo this using the <code>columns</code> utility. | |||
https://www.youtube.com/watch?v=uL7KvRskeog | |||
Latest revision as of 18:44, 16 January 2025
The following bash command will list all virsh guests in json.
echo "[ $(virsh list --all|grep -Ev 'Id|----'|awk '{print "{ \"id\": \""$1"\", \"name\": \""$2"\", \"state\": \""$3 $4"\"}," }'|head -n -1) {} ]"|jq -r
Output example:
[
{
"id": "38",
"name": "Mac",
"state": "running"
},
{
"id": "39",
"name": "Dennis",
"state": "running"
},
{
"id": "40",
"name": "Charlie",
"state": "running"
},
...
- TODO: Come back and redo this using the
columnsutility.