Skip to content

Instantly share code, notes, and snippets.

@OmgImAlexis
Created January 31, 2019 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OmgImAlexis/2335a56948b3cf0bae5fefa256f614d8 to your computer and use it in GitHub Desktop.
Save OmgImAlexis/2335a56948b3cf0bae5fefa256f614d8 to your computer and use it in GitHub Desktop.
co=$(docker inspect --format='{{.Name}}' $(docker ps -aq --no-trunc) | sed 's/^.\(.*\)/\1/' | sort); for c_name in $co; do c_size=$(docker inspect --format={{.ID}} $c_name | xargs -I @ sh -c 'ls -hl /var/lib/docker/containers/@/@-json.log' | awk '{print $5 }'); YE='\033[1;33m'; NC='\033[0m'; PI='\033[1;35m'; RE='\033[1;31m'; case "$c_size" in *"K"*) c_size=${YE}$c_size${NC};; *"M"*) p=${c_size%.*}; q=${p%M*}; r=${#q}; if [[ $r -lt 3 ]]; then c_size=${PI}$c_size${NC}; else c_size=${RE}$c_size${NC}; fi ;; esac; echo -e "$c_name $c_size"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment