Created
June 16, 2021 09:36
-
-
Save AndrewWCarson/a4a802175d94f2be1e04279f296c9975 to your computer and use it in GitHub Desktop.
Prints all non-system users, their home directory, and the size of the directory in human-readable format.
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/zsh | |
for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do | |
userHome=$(dscl . read /Users/"$user" NFSHomeDirectory | sed 's/NFSHomeDirectory://' | grep "/" | sed 's/^[ \t]*//') | |
if [ -d "$userHome" ]; then | |
size=$(/usr/bin/du -h -d 0 "$userHome" 2> /dev/null | awk '{print $1}') | |
echo "$user:$userHome:$size" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment