ls命令中-h的含义

-7 ls

[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
Run Code Online (Sandbox Code Playgroud)

我想了解hls -lrth命令。

ctr*_*lor 5

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

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

这意味着它将使用 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 = 2¹? = 2×2×2×2×2×2×2×2×2×2。(用于ls --si以 1000 的幂显示。)

边注

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

  • 请注意,[没有“_the_”`ls` 手册](https://unix.stackexchange.com/questions/433045/possible-versions-of-ls/433056#comment781981_433056)并且这个答案是一对夫妇所特有的`ls` 命令实际上 _have_ 一个 `--si` 选项。有几个有 `-h` 和没有 `--si`,两个有(参见 https://unix.stackexchange.com/questions/435123/ 的评论)在 `-h` 和 `--si 上有所不同` 实际输出,虽然人们不会仅仅从他们的手册中知道它。 (2认同)