我的实验如下:首先,建一个41字节的文件file1,查看一下内容。$ od -tc -ax file1000000 a b c d e 1 2 3 4 5 a b c d e 1000010 2 3 4 5 a b c d e 1 2 3 4 5 a b000020 c d e 1 2 3 4 5 \n000029由于用于实验的是一个单行文本文件,末尾有一个换行符。先拷贝前30字节到file2中。$ dd if=./file1 of=./file2 bs=30 count=1记录了1+0 的读入记录了1+0 的写出30字节(30 b)已复制,4.2609e-05 秒,704 kb/秒$ od -tc -ax file2000000 a b c d e 1 2 3 4 5 a b c d e 1000010 2 3 4 5 a b c d e 1 2 3 4 500001e然后,读取file1中的21~24共4个字节并附加到file2后面。$ dd if=./file1 of=./file2 conv=notrunc oflag=append ibs=4 skip=5 obs=4 count=1记录了1+0 的读入记录了1+0 的写出4字节(4 b)已复制,6.2934e-05 秒,63.6 kb/秒$ od -tc -ax file2000000 a b c d e 1 2 3 4 5 a b c d e 1000010 2 3 4 5 a b c d e 1 2 3 4 5 a b000020 c d000022最后,将file1第30个字节之后的内容全部读取出来并附加到file2后面。$ dd if=./file1 of=./file2 conv=notrunc oflag=append ibs=30 skip=1 obs=30记录了0+1 的读入记录了0+1 的写出11字节(11 b)已复制,6.1464e-05 秒,179 kb/秒$ od -tc -ax file2000000 a b c d e 1 2 3 4 5 a b c d e 1000010 2 3 4 5 a b c d e 1 2 3 4 5 a b000020 c d a b c d e 1 2 3 4 5 \n00002d这样就可以了。可以写成一个shell脚本(如下),并在每条dd命令中使用status=noxfer来抑制命令回显,使其静默执行。#!/bin/bashdd if=./file1 of=./file2 status=noxfer bs=30 count=1 >/dev/**dd if=./file1 of=./file2 status=noxfer conv=notrunc oflag=append ibs=4 skip=5 obs=4 count=1 >/dev/**dd if=./file1 of=./file2 conv=notrunc oflag=append ibs=30 skip=1 obs=30 >/dev/**exit 0 20210311