ls命令中-h的含义

ls命令中-h的含义
[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

我想了解一下h命令ls -lrth

答案1

from man ls(在 Gnu 系统上,但-h并非在所有ls系统上都可用)

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

这意味着它将使用 K、M、G 后缀显示文件大小:1K = 1024、1M = 1024K、1G = 1024M(全部以字节为单位)。看http://www.athropolis.com/popup/c-comp2.htm

这与公制 (SI) 系统的工作原理非常相似(1000μ = 1m、1000m = 1、1K = 1000、1M = 1000K、1G = 1000M),但是公制 si 系统使用的系数为 1000 = 10³ = 10×10 ×10,计算机系统使用因子 1024 = 21⁰ = 2×2×2×2×2×2×2×2×2×2。 (用于ls --si显示 1000 的幂。)

边注

这可能会令人困惑,因此发明了一个新的命名系统,即 1Ki = 1024、1Mi = 1024Ki、1Gi = 1024Mi。不幸的是,这些并没有被太多使用。它们确实出现在 ls 手册中,但没有出现在其用法中。它使用不带 i 的名称。

相关内容