app教程网 学习教程 linux中vi命令中dd怎么用(linux和unix的命令一样吗)

linux中vi命令中dd怎么用(linux和unix的命令一样吗)

Dd是Linux/UNIX下一个非常有用的命令,用来复制一个指定大小块的文件,同时进行指定的转换。

dd的主要选项:

如果指定了一个数字,则将其乘以下列字符末尾的相应数字:

b=512, c=1, k=1024, w=2, xm=number m

if=file

输入文件名,默认为标准输入。

of=file

输出文件名默认为标准输出。

ibs=bytes

一次读取字节(即块大小为字节)。

obs=bytes

一次写入字节(即块的大小为字节)。

bs=bytes

同时读写块的大小设置为字节,可以代替ibs和obs。

cbs=bytes

一次转换字节,即转换缓冲区大小。

skip=blocks

开始复制之前,跳过输入文件开头的块。

seek=blocks

开始复制之前,跳过输出文件开头的块。(通常仅当输出文件是磁盘或磁带时有效)

count=blocks

只复制块,块大小等于ibs指定的字节数。

conv=conversion[,conversion.]

用指定的参数转换文件。

转换参数:

American standard code for information interchange code converts the extended binary coded decimal interchange code into ASCII code.

The extended binary coded decimal interchange code is converted into EBCDIC.

American International Business Machines Corporation changed the American standard code for information interchange to replace EBCDIC.

Block将每一行转换成一条长度为cbs的记录,不足部分用空格填充。

unblock

把每行的长度做成cbs,不足的部分用空格填充。

Lcase将大写字符转换为小写字符。

Ucase将小写字符转换为大写字符。

Swab交换输入的每一对字节。不同于

Unix dd, this works when an odd number of

bytes are read. If the input file contains

an odd number of bytes, the last byte is

simply copied (since there is nothing to

swap it with).

noerror

出了问题不要停下来。

notrunc

不要截断输出文件。

Sync将每个输入块填充到ibs字节,不足部分用空字符填充。

因为dd命令允许二进制读写,所以特别适合在原始物理设备上进行输入/输出。例如,您可以使用以下命令为软盘创建镜像文件:

dd if=/dev/fd0 of=disk.img bs=1440k

有趣的是,这个图像文件可以通过HD-Copy和Winimage等工具读取。另一个例子是将第一个硬盘的前512个字节保存为文件:

dd if=/dev/hda of=disk.mbr bs=512 count=1

本文来自网络,不代表本站立场,转载请注明出处:https: