diff --git a/bin/ls/ls.1 b/bin/ls/ls.1 index d86250b82db..6aaa5025a6e 100644 --- a/bin/ls/ls.1 +++ b/bin/ls/ls.1 @@ -539,6 +539,10 @@ which are listed as the directory's contents and .Pa .. and other files which start with a dot, depending on other options). +If the +.Fl h +option is given, +the total size is displayed as the number of bytes. .Pp The default block size is 512 bytes. The block size may be set with option diff --git a/bin/ls/print.c b/bin/ls/print.c index f651dea5de9..a504ec63dc2 100644 --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -210,7 +210,14 @@ printlong(const DISPLAY *dp) if ((dp->list == NULL || dp->list->fts_level != FTS_ROOTLEVEL) && (f_longform || f_size)) { - (void)printf("total %lu\n", howmany(dp->btotal, blocksize)); + if (!f_humanval) + (void)printf("total %lu\n", howmany(dp->btotal, blocksize)); + else { + (void)humanize_number(buf, 7 /* "1024 KB" */, + dp->btotal * 512, "B", HN_AUTOSCALE, HN_DECIMAL); + + (void)printf("total %s\n", buf); + } } for (p = dp->list; p; p = p->fts_link) {