0

How to list all users and their total consumed space in multiple drives and just for a specific file extension? Basically similar to the output below:

User1 15T /datadrive01
User2 10T /datadrive01
User3 11gb /datadrive01

User1 20T /datadrive02
User2 10gb /datadrive02
User3 5gb /datadrive02
Guthrie
  • 13
  • 3

1 Answers1

0

This will take a while:

for mnt in /datadrive01 /datadrive02; do
    find "$mnt" -printf '%u %k\n' 2>/dev/null \
      | awk -v "mnt=$mnt" '{sum[$1]+=$2} END {for (u in sum) print u,sum[u],mnt}' \
      | numfmt --from-unit=1000 --to=iec --field=2
    echo
done
  • find all files and print user and disk usage of size (-printf '%u %k\n')
  • with awk sum up all sizes per user and print.
  • with numfmt optionally convert sizes to human-readable format
  • echo just for the blank line in between
pLumo
  • 22,565