[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature Request: du --dir-with-slash
From: |
Pádraig Brady |
Subject: |
Re: Feature Request: du --dir-with-slash |
Date: |
Fri, 7 Mar 2008 15:46:35 +0000 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071008) |
Thomas Guettler wrote:
> Hi,
>
> 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.
How about the attaced patch?
cheers,
Pádraig.
>From 0d9130e0bd8b4f09be181e8e7afabdacfb872482 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?P=C3=A1draig=20Brady?= <address@hidden>
Date: Fri, 7 Mar 2008 15:44:34 +0000
Subject: [PATCH] Ensure du outputs a trailing / for directories.
* src/du.c: This allows one to distinguish directories
in `du -a` output. Suggestion from Thomas Guettler <address@hidden>
Signed-off-by: Pádraig Brady <address@hidden>
---
ChangeLog-2008 | 5 +++++
src/du.c | 11 +++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/ChangeLog-2008 b/ChangeLog-2008
index aac9feb..279530a 100644
--- a/ChangeLog-2008
+++ b/ChangeLog-2008
@@ -1,3 +1,8 @@
+2008-03-07 Pádraig Brady <address@hidden>
+
+ * src/du.c: Ensure the directories output by du
+ have a trailing '/' so that they can be distinguished in `du -a` output
+
2008-02-07 Jim Meyering <address@hidden>
We *do* need two different version files.
diff --git a/src/du.c b/src/du.c
index 6681079..25aaa99 100644
--- a/src/du.c
+++ b/src/du.c
@@ -437,7 +437,7 @@ print_only_size (uintmax_t n_bytes)
/* Print size (and optionally time) indicated by *PDUI, followed by STRING. */
static void
-print_size (const struct duinfo *pdui, const char *string)
+print_size (const struct duinfo *pdui, const char *string, const struct stat
*sb)
{
print_only_size (pdui->size);
if (opt_time)
@@ -445,7 +445,10 @@ print_size (const struct duinfo *pdui, const char *string)
putchar ('\t');
show_date (time_format, pdui->tmax);
}
- printf ("\t%s%c", string, opt_nul_terminate_output ? '\0' : '\n');
+ printf ("\t%s%s%c",
+ string,
+ sb && S_ISDIR(sb->st_mode) ? "/" : "",
+ opt_nul_terminate_output ? '\0' : '\n');
fflush (stdout);
}
@@ -607,7 +610,7 @@ process_file (FTS *fts, FTSENT *ent)
if ((IS_DIR_TYPE (ent->fts_info) && level <= max_depth)
|| ((opt_all && level <= max_depth) || level == 0))
- print_size (&dui_to_print, file);
+ print_size (&dui_to_print, file, sb);
return ok;
}
@@ -653,7 +656,7 @@ du_files (char **files, int bit_flags)
}
if (print_grand_total)
- print_size (&tot_dui, _("total"));
+ print_size (&tot_dui, _("total"), NULL);
return ok;
}
--
1.5.3.6
- Feature Request: du --dir-with-slash, Thomas Guettler, 2008/03/06
- Re: Feature Request: du --dir-with-slash, Jim Meyering, 2008/03/06
- Re: Feature Request: du --dir-with-slash, Pádraig Brady, 2008/03/06
- Re: Feature Request: du --dir-with-slash,
Pádraig Brady <=
- Re: Feature Request: du --dir-with-slash, Thomas Guettler, 2008/03/10
- Re: Feature Request: du --dir-with-slash, Pádraig Brady, 2008/03/10
- Re: Feature Request: du --dir-with-slash, Jim Meyering, 2008/03/10
- Re: Feature Request: du --dir-with-slash, Pádraig Brady, 2008/03/10
- Re: Feature Request: du --dir-with-slash, Thomas Guettler, 2008/03/10
- Re: Feature Request: du --dir-with-slash, Pádraig Brady, 2008/03/10