dd
1. Role
dd command to copy files and converts the data according to the parameters and formats.
2. Format
dd [options]
3. [opitions] Specifications
- if = file name: Enter the file name, the default is standard input. That is, to specify the source file.
- of = file name: output file name defaults to the standard output. That is, specify the destination file.
- ibs = bytes: byte read into bytes, i.e., a block size of bytes specified bytes.
obs = bytes: one byte output bytes, i.e., a block size of bytes specified bytes.
bs = bytes: while providing read / output block size bytes bytes. - cbs = bytes: byte conversion bytes that specify a translation buffer size.
- skip = blocks: blocks skipped blocks from beginning of the input file and then begins copying.
- seek = blocks: blocks skipped blocks from beginning of output file before starting copying.
- count = blocks: copy only blocks block, the block size is equal to the number of bytes specified ibs.
- conv = <key>, can have the following 11 kinds of keywords:
- conversion: convert file with the specified parameters.
- ascii: ebcdic convert to ascii
- ebcdic: convert to ascii ebcdic
- ibm: ascii convert to alternate ebcdic
- block: The length of each line is converted to cbs, insufficient space partially filled with
- unblock: that the length of each row are padded with spaces to cbs, the shortage
- lcase: uppercase characters to lowercase characters
- ucase: the lowercase characters converted to uppercase
- swab: switching each pair of input byte
- noerror: do not stop when an error occurs
- notrunc: do not truncate the output file
- sync: each input block to ibs bytes, less than some empty (the NUL) character filled.
- --help: Displays help information
- --version: display version information
4. Application Examples
(1) make a boot disk under Linux, use the command:
dd if=boot.img of=/dev/fd0 bs=1440k
(2) the file testfile all converted to uppercase letters, and then turn to become testfile_1 file, using the following at the command prompt:
dd if=testfile_2 of=testfile_1 conv=ucase
Testfile_2 of which reads:
$ cat testfile_2 #testfile_2的内容
HELLO LINUX!
Linux is a free unix-type opterating system.
This is a linux testfile!
Linux test
After the conversion is complete, the contents testfile_1 follows:
$ dd if=testfile_2 of=testfile_1 conv=ucase #使用dd 命令,大小写转换记录了0+1 的读入
记录了0+1 的写出
95字节(95 B)已复制,0.000131446 秒,723 KB/s
cmd@hdd-desktop:~$ cat testfile_1 #查看转换后的testfile_1文件内容
HELLO LINUX!
LINUX IS A FREE UNIX-TYPE OPTERATING SYSTEM.
THIS IS A LINUX TESTFILE!
LINUX TEST #testfile_2中的所有字符都变成了大写字母
(3) by a standard input device reads the character string, and the string to uppercase, and then output to the standard output device, the command used is:
dd conv=ucase
After entering the above command and press Enter, the input string, press the Enter key, press the key combination Ctrl + D to exit, the following results occur:
$ dd conv=ucase
Hello Linux! #输入字符串后按回车键
HELLO LINUX! #按组合键Ctrl+D退出,转换成大写结果
记录了0+1 的读入
记录了0+1 的写出
13字节(13 B)已复制,12.1558 秒,0.0 KB/s