1
1
/* du -- summarize disk usage
2
Copyright (C) 1988-2012 Free Software Foundation, Inc.
2
Copyright (C) 1988-2013 Free Software Foundation, Inc.
4
4
This program is free software: you can redistribute it and/or modify
5
5
it under the terms of the GNU General Public License as published by
147
147
is at level 0, so 'du --max-depth=0' is equivalent to 'du -s'. */
148
148
static size_t max_depth = SIZE_MAX;
150
/* Only output entries with at least this SIZE if positive,
151
or at most if negative. See --threshold option. */
152
static intmax_t opt_threshold = 0;
150
154
/* Human-readable options for output. */
151
155
static int human_output_opts;
218
222
{"separate-dirs", no_argument, NULL, 'S'},
219
223
{"summarize", no_argument, NULL, 's'},
220
224
{"total", no_argument, NULL, 'c'},
225
{"threshold", required_argument, NULL, 't'},
221
226
{"time", optional_argument, NULL, TIME_OPTION},
222
227
{"time-style", required_argument, NULL, TIME_STYLE_OPTION},
223
228
{GETOPT_HELP_OPTION_DECL},
268
273
"), program_name, program_name);
270
275
Summarize disk usage of each FILE, recursively for directories.\n\
274
Mandatory arguments to long options are mandatory for short options too.\n\
278
emit_mandatory_arg_note ();
281
-0, --null end each output line with 0 byte rather than newline\n\
277
282
-a, --all write counts for all files, not just directories\n\
278
283
--apparent-size print apparent sizes, rather than disk usage; although\
289
294
-c, --total produce a grand total\n\
290
295
-D, --dereference-args dereference only symlinks that are listed on the\n\
297
-d, --max-depth=N print the total for a directory (or file, with --all)\n\
298
only if it is N or fewer levels below the command\n\
299
line argument; --max-depth=0 is the same as\n\
294
303
--files0-from=F summarize disk usage of the NUL-terminated file\n\
297
306
-H equivalent to --dereference-args (-D)\n\
298
307
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\
300
--si like -h, but use powers of 1000 not 1024\n\
303
311
-k like --block-size=1K\n\
312
-L, --dereference dereference all symbolic links\n\
304
313
-l, --count-links count sizes many times if hard linked\n\
305
314
-m like --block-size=1M\n\
308
-L, --dereference dereference all symbolic links\n\
309
317
-P, --no-dereference don't follow any symbolic links (this is the default)\n\
310
-0, --null end each output line with 0 byte rather than newline\n\
311
318
-S, --separate-dirs do not include size of subdirectories\n\
319
--si like -h, but use powers of 1000 not 1024\n\
312
320
-s, --summarize display only a total for each argument\n\
315
-x, --one-file-system skip directories on different file systems\n\
316
-X, --exclude-from=FILE exclude files that match any pattern in FILE\n\
317
--exclude=PATTERN exclude files that match PATTERN\n\
318
-d, --max-depth=N print the total for a directory (or file, with --all)\n\
319
only if it is N or fewer levels below the command\n\
320
line argument; --max-depth=0 is the same as\n\
323
-t, --threshold=SIZE exclude entries smaller than SIZE if positive,\n\
324
or entries greater than SIZE if negative\n\
324
325
--time show time of the last modification of any file in the\n\
325
326
directory, or any of its subdirectories\n\
326
327
--time=WORD show time as WORD instead of modification time:\n\
329
330
full-iso, long-iso, iso, +FORMAT\n\
330
331
FORMAT is interpreted like 'date'\n\
334
-X, --exclude-from=FILE exclude files that match any pattern in FILE\n\
335
--exclude=PATTERN exclude files that match PATTERN\n\
336
-x, --one-file-system skip directories on different file systems\n\
332
338
fputs (HELP_OPTION_DESCRIPTION, stdout);
333
339
fputs (VERSION_OPTION_DESCRIPTION, stdout);
334
340
emit_blocksize_note ("DU");
579
585
duinfo_add (&tot_dui, &dui);
581
587
if ((IS_DIR_TYPE (info) && level <= max_depth)
582
|| ((opt_all && level <= max_depth) || level == 0))
583
print_size (&dui_to_print, file);
588
|| (opt_all && level <= max_depth)
591
/* Print or elide this entry according to the --threshold option. */
592
if (opt_threshold < 0
593
? dui_to_print.size <= -opt_threshold
594
: dui_to_print.size >= opt_threshold)
595
print_size (&dui_to_print, file);
706
int c = getopt_long (argc, argv, "0abd:chHklmsxB:DLPSX:",
719
int c = getopt_long (argc, argv, "0abd:chHklmst:xB:DLPSX:",
707
720
long_options, &oi);
784
797
opt_summarize_only = true;
803
e = xstrtoimax (optarg, NULL, 0, &opt_threshold, "kKmMGTPEZY0");
805
xstrtol_fatal (e, oi, c, long_options, optarg);
806
if (opt_threshold == 0 && *optarg == '-')
808
/* Do not allow -0, as this wouldn't make sense anyway. */
809
error (EXIT_FAILURE, 0, _("invalid --threshold argument '-0'"));
788
815
bit_flags |= FTS_XDEV;