Created
June 12, 2014 09:00
-
-
Save davidpelaez/41c4c3ac6c6f619f9244 to your computer and use it in GitHub Desktop.
shell script to list all geard installed containers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd /var/lib/containers/units | |
units=$(find . -maxdepth 2 | grep '.service' | awk -F'/' '{print $3}') | |
keys=( LoadState ActiveState SubState UnitFileState ) | |
result="" | |
for unit in $units; do | |
unit_info=$(systemctl show "$unit") | |
result="${result}${unit}" | |
#echo -n "$unit" | |
for query_key in "${keys[@]}"; do | |
result="$result $(echo "$unit_info" | grep $query_key | awk -F'=' '{printf " %s", $2}')" | |
done | |
result="$result\n" | |
done | |
echo -e "$result" | column -t -s ' ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sampel output: