[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Did I found a bug in "ls"?
From: |
Major Péter |
Subject: |
Re: Did I found a bug in "ls"? |
Date: |
Sun, 08 Mar 2009 19:26:08 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20090105) |
Hi,
I need to write a script, which will print out on the standard output,
that each user how many disk space (in blocks) are using in a directory
(and subdirectories, the directory is a parameter).
So an example output would look like this:
root:101711
user1:940258
The main problem with du is, that it doesn't care with users, so I need
a "find" before (using the -user will solve the problem). But I can't
use du `find ...` because it will contain the subfolders too, so it will
duplicate, and the measure won't be correct. (Or if I'm use the
--max-depth option it will still not care with the user filtering).
So by now I have this:
du `find . -type f -user foobar`
using sed, and a for cycle I can make a sum from this values.
But now, I don't have the sizes of the directories, so that's why I
tried to use:
ls `find . -type d -user foo -name "*"` # -name "*" will be removed in
the final version
but didn't worked, so I wrote here a mail.
If you know a better way, please just send me a command or parameter
name, because this is my homework. :)
I will use the -print0 parameter with xargs.
Thanks for helping me.
Regards,
Peter
Philip Rowlands írta:
On Sun, 8 Mar 2009, Major Péter wrote:
I would like to list some folders with they block-sizes, but only
specific folders am I interested.
So I would like to use find to list the correct folders for me:
ls `find . -type d -user foo -name "*"`
this is not working because ls can't find folders with spaces in
there name,
find uses an implicit "-print" argument, but in this case please look
at find's "-print0" option. This version of the above command should
work:
$ find . -type d -user foo -print0 | xargs -0 ls
(-name "*" is redundant, as everything matches)
I'm still not sure what you're referring to by folders with
block-sizes? Would the du command be helpful here?
Cheers,
Phil