Add -k support for du(1)
This setting overrides the BLOCKSIZE environment variable.
This commit is contained in:
parent
6e8b79ebd8
commit
ac3a5e0091
4
du.1
4
du.1
@ -19,3 +19,7 @@ Display an entry for each file in the file hierarchy.
|
|||||||
.TP
|
.TP
|
||||||
.BI \-s
|
.BI \-s
|
||||||
Display only the grand total for the specified files.
|
Display only the grand total for the specified files.
|
||||||
|
.TP
|
||||||
|
.BI \-k
|
||||||
|
By default all sizes are reported in 512-byte block counts.
|
||||||
|
The -k option causes the numbers to be reported in kilobyte counts.
|
||||||
|
7
du.c
7
du.c
@ -15,6 +15,7 @@ static long blksize = 512;
|
|||||||
|
|
||||||
static bool aflag = false;
|
static bool aflag = false;
|
||||||
static bool sflag = false;
|
static bool sflag = false;
|
||||||
|
static bool kflag = false;
|
||||||
|
|
||||||
static long du(const char *);
|
static long du(const char *);
|
||||||
static void print(long n, char *path);
|
static void print(long n, char *path);
|
||||||
@ -38,6 +39,9 @@ main(int argc, char *argv[])
|
|||||||
case 's':
|
case 's':
|
||||||
sflag = true;
|
sflag = true;
|
||||||
break;
|
break;
|
||||||
|
case 'k':
|
||||||
|
kflag = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
@ -46,6 +50,9 @@ main(int argc, char *argv[])
|
|||||||
if (bsize)
|
if (bsize)
|
||||||
blksize = estrtol(bsize, 0);
|
blksize = estrtol(bsize, 0);
|
||||||
|
|
||||||
|
if (kflag)
|
||||||
|
blksize = 1024;
|
||||||
|
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
n = du(".");
|
n = du(".");
|
||||||
if (sflag)
|
if (sflag)
|
||||||
|
Loading…
Reference in New Issue
Block a user