某些版本的 dd 不理解乘法后缀吗?

do some versions of dd not understand multiplicative suffixes?

我想知道是否有某些版本的 dd 不理解乘法后缀。从 dd 手册页说:

bs=BYTES
    read and write BYTES bytes at a time (also see ibs=,obs=) 
BLOCKS and BYTES may be followed by the following multiplicative suffixes: c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

但是当我 运行 dd 在 bs 参数上带有 G 后缀时,我得到了一个关于数字不被理解的错误:

bash $ dd if=/dev/urandom of=largeMovie.avi count=1024 bs=75G
dd: invalid number `75G'

dd版本如下:

bash $ dd --version
dd (coreutils) 5.97

一个

我认为您使用的是 32 位,75G 比 size_t 大。 即使在 64 位上,您也至少需要可用的内存数量,因为 dd 将分配 bs 指定大小的缓冲区。

G 不是标准后缀。因此,行为未定义。

唯一的标准后缀是 k (1024) 和 b (512)。如果你还想要其他的,你可以在几个带后缀的数字之间使用x来相乘:

dd bs=1024 count=75x1024x1024x1024

(您的示例尝试分配 75GiB 的 RAM,这很少能成功,所以我切换了 bscount

POSIX 是这样说的:

For the bs=, cbs=, ibs=, and obs= operands, the application shall supply an expression specifying a size in bytes. The expression, expr, can be:

A positive decimal number

A positive decimal number followed by k, specifying multiplication by 1024

A positive decimal number followed by b, specifying multiplication by 512

Two or more positive decimal numbers (with or without k or b) separated by x, specifying the product of the indicated values