dd_linux_command

dd命令

文件输入输出

1
2
3
#if= 接输入文件
#of= 接输出文件
dd if=/dev/zero of=./zero.file

字节数调整

1
2
3
4
#bs= 设置输入文件 输出文件 块大小
#ibs= 仅设置输入文件 块大小
#obs= 仅设置输出文件 块大小
dd if=/dev/zero of=./zero.file bs=4096

指定参数转换文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#conv=指定参数 
# ascii ebcdic转换为ascii
# ebcdic ascii转换为ebcdic
# ibm ascii转换为alternate ebcdic
dd if=test of=out conv=ebcdic

#cbs= 设置每次转换缓冲区大小
dd if=test of=out conv=ebcdic cbs=1024

#block 把每一行转换位长度位cbs 不足部分用空格填充
dd if=test of=out cbs=16 conv=block,ebcdic
#unblock 使每一行的长度都为cbs 不足部分用空格填充
dd if=test of=out cbs=32 conv=unblock,ascii

#lcase 把大写字母转为小写
dd if=test of=out cbs=16 conv=lcase,ascii
#ucase 把小写字母转为大写
dd if=test of=out cbs=64 conv=ucase,ebcdic

#swab 交换输入的每对字节
dd if=test of=out cbs=2 conv=swab

#noerror 出错时不停止
#notrunc 不截短输出文件
#sync 将每个输入块填充盗ibs个字节

跳过一定字节再开始复制

1
2
3
4
5
#skip=nblocks 从输入文件开头跳过n个块后再开始复制
dd if=test of=out skip=10

#seek=nblocks 从输出文件开头跳过n个块后再开始复制
dd if=test of=out seek=12