1

I need to help a specific user, say alice, free up some disk space; but not all the user's files are in his home directory; many are in directories shared with other users. I'd like to have something like the output of

du -sh *

but limited to the files that belong to that user only. I.e., something like,

du -sh --ignore-all-users-except=alice *

So, for example, if in the current directory there are three directories, a, b and c, I'd like to see output such as the following:

1.3G   a
416K   b
80K    c

meaning that alice is using 1.3G inside a, 416K inside b, and so on.

Is there any utility that can give me such information, or do I need a script?

Antonis Christofides
  • 2,556
  • 2
  • 22
  • 35

2 Answers2

4
find / -user alice -print0 | du -ch --files0-from=-
quanta
  • 50,327
  • 19
  • 152
  • 213
  • Thanks. This is indeed good as a starting point. It misses ``-type f`` (otherwise it counts some files twice or more times if they are inside a directory owned by alice), and I also use ``tail -n 1``. Actually the full command that does what I want is ``for x in *; do find $x -type f -user alice -print0 | du -ch --files0-from=-|tail -n 1|awk '{ printf "%-10s", $1 }'; echo $x; done`` – Antonis Christofides Jul 10 '13 at 09:50
0

I think this will do.

find . -user alice -type f -exec du -h {} +

Update: You might want to check the answers here

user
  • 1,408
  • 8
  • 10
  • Neither the find command nor the linked post does what I want, as the first gives a huge list of files and the second concerns usage across the entire file system, whereas I want a sum per specific directories. – Antonis Christofides Jul 10 '13 at 10:04