私はddコマンドにすっかり慣れていますが、自分で使用する必要はほとんどありません。今日はそうする必要がありますが、本当に奇妙に思える行動に遭遇しています。
1億のテキストファイルを作成したいと思います。各行には「testing」という1つの単語が含まれています。これは私の最初の試みでした:
~$ 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
したがって、これら4つの明らかに同等のコマンドのうち、すべてが異なるサイズのファイルを生成しますが、そのうちの1つだけが私が期待するものです。何故ですか?
編集:までに、私はその長いPerlコマンドの代わりに「はいテスト」を考えていなかったので少し恥ずかしいです。