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?

0

2 Answers 2

4
find / -user alice -print0 | du -ch --files0-from=- 
1
  • 1
    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 Commented Jul 10, 2013 at 9:50
0

I think this will do.

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

Update: You might want to check the answers here

1
  • 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. Commented Jul 10, 2013 at 10:04

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.