作者MortonRainey (MortonRainey)
看板Linux
标题Re: [问题] dd 指令问题.
时间Wed Jun 4 23:05:42 2008
※ 引述《[email protected] (风)》之铭言:
: ※ 引述《[email protected] (MortonRainey)》之铭言:
: 如果是要填 0 的话:
: dd if=/dev/zero of=ifile conv=notrunc oflag=append bs=1 count=12
: > 不好意思再次请教各位先进这个问题。
: > 若是不用dd指令,有其他的方法达成吗?
: 一样假设要填 0 的话:
: head -c 12 /dev/zero >> ifile
: * 操作实例:假设原档案是从 /dev/random 产生的 10 bytes 大小的档案,
: 想要在档案尾端填 0 直到档案大小变成 20 bytes。
: * 产生两个相同的 10 bytes 的档案 test.dd 和 test.head
: $ dd if=/dev/random of=./test.dd bs=1 count=10
: 10+0 records in
: 10+0 records out
: 复制了 10 位元组 (10 B),0.000459235 秒,21.8 kB/s
: $ cp test.dd test.head
: $ ls -l test.*
: -rw-r--r-- 1 storm storm 10 2008-06-03 15:05 test.dd
: -rw-r--r-- 1 storm storm 10 2008-06-03 15:07 test.head
: * 使用 dd 填 0
: $ dd if=/dev/zero of=test.dd conv=notrunc oflag=append bs=1 count=10
: 10+0 records in
: 10+0 records out
: 复制了 10 位元组 (10 B),0.000134921 秒,74.1 kB/s
: $ ls -l test.dd
: -rw-r--r-- 1 storm storm 20 2008-06-03 15:09 test.dd
: * 使用 head 填 0
: $ head -c 10 /dev/zero >> test.head
: $ ls -l test.head
: -rw-r--r-- 1 storm storm 20 2008-06-03 15:11 test.head
: * 验证档案内容
: $ diff test.dd test.head && echo '档案内容一致'
: 档案内容一致
: $ hexdump test.dd
: 0000000 2d57 09bf cb4e 5118 6fb3 0000 0000 0000
: 0000010 0000 0000
: 0000014
谢谢大大详细的解说,不过这个方法需自行算出欲append的bytes数,
此外填充值能改成其他的值如0xFF吗?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.193.253.31