bash – 根本不了解dd命令参数

我熟悉dd命令,但我很少需要自己使用它.今天我需要,但是我遇到似乎很奇怪的行为.

我想创建一个100M的文本文件,其中每一行都包含单词“测试”.这是我第一次尝试:

~$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命令.

我还不知道为什么,但使用这种方法在保存之前不会填满整个块.尝试:
perl -e 'print "testing\n" while 1' | dd of=output.txt bs=10K count=10K iflag=fullblock
10240+0 records in
10240+0 records out
104857600 bytes (105 MB) copied,2.79572 s,37.5 MB/s

iflag = fullblock似乎强制dd累积输入,直到块已满,虽然我不知道为什么这不是默认值,或者它实际上是默认的.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...