Thomas Guettler <[EMAIL PROTECTED]> wrote:
> I use "du -ax / | sort -rn > /var/tmp/du-`date --iso`" to get the sorted
> total size of all
> files and directories.
>
> Unfortunately you can't see a difference between a directory and a file
> in the output. It would be nice if the directories would be added by a
> slash.
>
> Example:
>
> old:
> 307704984       /
> 291330280       /home
>
> new:
> 307704984       /
> 291330280       /home/
>
> This way you can see if a line is a directory or not. This is even more
> important
> if you want to use the output for a script.
>
> I suggest 'du --dir-with-slash' or 'du --trailing-slash' as parameter.

Thanks for the suggestion, but rather than adding an option,
how about wrapping a small script around du?
Use du's --zero (-0) option to make it work even with
names containing newline:

mkdir j && cd j && touch a b && mkdir d d2 &&
  du -a -0|perl -0 -ne \
    'chomp; /^\d+\t(.*)/ and print "$_", (-d $1 ? "/" : ""), "\n"'

0       ./d2/
0       ./d/
0       ./b
0       ./a
0       ./

Of course, that will convert "/" to "//", but it's just a one-liner, too.
I'm sure you can adapt.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to