-8
[root@pdbosl02 daily]# ls -lrth
total 12G
-rw-r----- 1 oracle dba 3.8G Dec  7 20:43 BKPOSLPRD_jcns9p1f.F_bkp
-rw-r----- 1 oracle dba 4.2G Dec  7 20:46 BKPOSLPRD_jdns9p1f.F_bkp
-rw-r----- 1 oracle dba 3.0G Dec  7 20:51 BKPOSLPRD_jbns9p1f.F_bkp
-rw-r----- 1 oracle dba 140M Dec  7 20:52 ALG_OSLPRD_jgns9rfr.alg
-rw-r----- 1 oracle dba 189M Dec  7 20:52 ALG_OSLPRD_jfns9rfr.alg
-rw-r----- 1 oracle dba 202M Dec  7 20:52 ALG_OSLPRD_jens9rfr.alg
-rw-r----- 1 oracle dba  42M Dec  7 20:52 c-4249173797-20121207-00
-rw-r----- 1 oracle dba  41M Dec  7 20:52 ctrl_071223

I want to know about h in ls -lrth command.

gandhi
  • 7

1 Answers1

5

from man ls (on a Gnu system, but -h is not available in all lss)

-h, --human-readable
              with  -l and/or -s, print human readable sizes (e.g., 1K
              234M 2G)

Meaning that it will display file sizes using K, M, G postfixes: 1K = 1024, 1M = 1024K, 1G = 1024M (all in bytes). see http://www.athropolis.com/popup/c-comp2.htm

This is very similar to how the metric (SI) system works ( 1000μ = 1m, 1000m = 1, 1K = 1000, 1M = 1000K, 1G = 1000M ) however the metric si system uses a factor of 1000 = 10³ = 10×10×10, and the computer system uses a factor of 1024 = 2¹⁰ = 2×2×2×2×2×2×2×2×2×2. (Use ls --si to show in powers of 1000.)

Side note

This can be confusing so a new naming system was invented so 1Ki = 1024, 1Mi = 1024Ki, 1Gi = 1024Mi. Unfortunately these are not used much. They do appear in the ls manual, but not in its usage. It uses the names without the i.

  • 2
    Note that there is no "the" ls manual and this answer is peculiar to the couple of ls commands that actually have an --si option. Several have -h and no --si, and the two that have (see commentary at https://unix.stackexchange.com/questions/435123/) differ on what -h and --si actually output, although one wouldn't know it purely from their manuals alone. – JdeBP Apr 04 '18 at 23:01