Add -g (gigabyte) flag to complement -k (kilobyte) and -m (megabyte).

MFC after:	1 week
This commit is contained in:
Dag-Erling Smørgrav 2012-07-18 19:28:22 +00:00
parent ce61627a2d
commit 69739e8da5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=238602
2 changed files with 13 additions and 7 deletions

View File

@ -28,7 +28,7 @@
.\" @(#)du.1 8.2 (Berkeley) 4/1/94 .\" @(#)du.1 8.2 (Berkeley) 4/1/94
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd December 17, 2011 .Dd July 18, 2012
.Dt DU 1 .Dt DU 1
.Os .Os
.Sh NAME .Sh NAME
@ -38,7 +38,7 @@
.Nm .Nm
.Op Fl Aclnx .Op Fl Aclnx
.Op Fl H | L | P .Op Fl H | L | P
.Op Fl h | k | m .Op Fl g | h | k | m
.Op Fl a | s | d Ar depth .Op Fl a | s | d Ar depth
.Op Fl B Ar blocksize .Op Fl B Ar blocksize
.Op Fl I Ar mask .Op Fl I Ar mask
@ -63,9 +63,9 @@ Calculate block counts in
.Ar blocksize .Ar blocksize
byte blocks. byte blocks.
This is different from the This is different from the
.Fl h, k .Fl h, k, m
and and
.Fl m .Fl g
options or setting options or setting
.Ev BLOCKSIZE .Ev BLOCKSIZE
and gives an estimate of how much space the examined file hierarchy would and gives an estimate of how much space the examined file hierarchy would
@ -95,13 +95,15 @@ Display a grand total.
Display an entry for all files and directories Display an entry for all files and directories
.Ar depth .Ar depth
directories deep. directories deep.
.It Fl g
Display block counts in 1073741824-byte (1 GiB) blocks.
.It Fl h .It Fl h
.Dq Human-readable .Dq Human-readable
output. output.
Use unit suffixes: Byte, Kilobyte, Megabyte, Use unit suffixes: Byte, Kilobyte, Megabyte,
Gigabyte, Terabyte and Petabyte. Gigabyte, Terabyte and Petabyte.
.It Fl k .It Fl k
Display block counts in 1024-byte (1-Kbyte) blocks. Display block counts in 1024-byte (1 kiB) blocks.
.It Fl l .It Fl l
If a file has multiple hard links, count its size multiple times. If a file has multiple hard links, count its size multiple times.
The default behavior of The default behavior of
@ -112,7 +114,7 @@ When the
option is specified, the hard link checks are disabled, and these files option is specified, the hard link checks are disabled, and these files
are counted (and displayed) as many times as they are found. are counted (and displayed) as many times as they are found.
.It Fl m .It Fl m
Display block counts in 1048576-byte (1-Mbyte) blocks. Display block counts in 1048576-byte (1 MiB) blocks.
.It Fl n .It Fl n
Ignore files and directories with user Ignore files and directories with user
.Dq nodump .Dq nodump

View File

@ -109,7 +109,7 @@ main(int argc, char *argv[])
depth = INT_MAX; depth = INT_MAX;
SLIST_INIT(&ignores); SLIST_INIT(&ignores);
while ((ch = getopt(argc, argv, "AB:HI:LPasd:chklmnrt:x")) != -1) while ((ch = getopt(argc, argv, "AB:HI:LPasd:cghklmnrt:x")) != -1)
switch (ch) { switch (ch) {
case 'A': case 'A':
Aflag = 1; Aflag = 1;
@ -156,6 +156,10 @@ main(int argc, char *argv[])
case 'c': case 'c':
cflag = 1; cflag = 1;
break; break;
case 'g':
hflag = 0;
blocksize = 1073741824;
break;
case 'h': case 'h':
hflag = 1; hflag = 1;
break; break;