Last active
June 19, 2020 06:37
-
-
Save joxl/56f259edb06d70a758945120c459c3d2 to your computer and use it in GitHub Desktop.
Get indexing status of all volumes known to mdutil
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
#!/usr/bin/env bash | |
vols=() | |
maxwidth=0 | |
while read -r vol; do | |
vols+=( "$vol" ) | |
maxwidth=$(echo -e "${maxwidth}\n${#vol}" | sort -n | tail -n1) | |
done < <(mdutil -a 2>&1 | awk -F: '{print $1}') | |
fmt="%-${maxwidth}s %s\n" | |
for vol in "${vols[@]}"; do | |
# yuck, BSD sed sucks :( | |
# see: https://stackoverflow.com/questions/4438306/how-to-remove-trailing-whitespaces-with-sed/4438318#15416836 | |
status=$(mdutil -s "$vol" | tail -n +2 | sed -E 's/(^[[:space:]]*|[[:space:]]*$)//g') | |
printf "$fmt" "$vol" "$status" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rationale and example: