Created
February 13, 2025 07:11
-
-
Save filipnet/beed6db0289cd3532de2981ae4516c8d to your computer and use it in GitHub Desktop.
This script extracts all home directories from /etc/passwd, regardless of their location. It then checks if each home directory contains a Maildir folder. If a Maildir exists, the script displays the total size of the home directory along with the size of the Maildir and its subdirectories.
This file contains hidden or 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 | |
| # Get all home directories from /etc/passwd | |
| HOMEDIRS=$(awk -F: '$6 !~ /^$/ {print $6}' /etc/passwd | sort -u) | |
| # Loop through each home directory | |
| for dir in $HOMEDIRS; do | |
| MAILDIR="$dir/Maildir" | |
| # Check if the Maildir exists | |
| if [ -d "$MAILDIR" ]; then | |
| echo "=== $dir ===" | |
| du -h --max-depth=2 "$dir" | grep -E "^|/Maildir" | |
| echo "" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment