我对 dd 命令非常熟悉,但我很少需要自己使用它。今天我需要,但我遇到的行为似乎很奇怪。
我想创建一个 100M 的文本文件,其中每一行都包含一个单词“testing”。这是我的第一次尝试:
~$ perl -e 'print "testing\n" while 1' | dd of=X bs=1M count=100
0+100 records in
0+100 records out
561152 bytes (561 kB) copied, 0.00416429 s, 135 MB/s
嗯,这很奇怪。其他组合呢?
~$ perl -e 'print "testing\n" while 1' | dd of=X bs=100K count=1K
0+1024 records in
0+1024 records out
4268032 bytes (4.3 MB) copied, 0.0353145 s, 121 MB/s
~$ perl -e 'print "testing\n" while 1' | dd of=X bs=10K count=10K
86+10154 records in
86+10154 records out
42524672 bytes (43 MB) copied, 0.35403 s, 120 MB/s
~$ perl -e 'print "testing\n" while 1' | dd of=X bs=1K count=100K
102400+0 records in
102400+0 records out
104857600 bytes (105 MB) copied, 0.879549 s, 119 MB/s
因此,在这四个表面上等效的命令中,都生成了不同大小的文件,其中只有一个是我所期望的。这是为什么?
编辑:顺便说一句,我有点尴尬,我没有想到“是的测试”而不是那个更长的 Perl 命令。