【发布时间】:2013-03-12 13:49:48
【问题描述】:
是否可以在循环中使用 dd 将二进制文件 myfile 中的字节从一个特定位置替换到另一个位置,还是使用另一个命令更方便?
这个想法是在循环中用 position1 的块 A 替换位置 position2 的块 B .
伪代码
@ l = 0
while (l <= bytelength of myfile)
copy myfile (from position1 to A+position1) myfile from (position2 to B+position2)
@ position1 = position1+steplength
@ position2 = position2+steplength
@ l = l+steplength
end
【问题讨论】:
-
虽然可能,但我不会使用 shell 命令语言来进行这种类型的文件操作。使用对此类文件 I/O 提供更好支持的语言。无论哪种情况,您是覆盖
position2处的字节,还是只是重新排列文件中的字节顺序? -
如果可能我想覆盖它们...
标签: shell byte block dd substitution