Latest web development tutorials

Linux dd command

Linux dd command

Linux command Daquan Linux command Daquan

Linux dd command is used to read, convert and output data.

dd can be read from standard input or the data in the file, according to the specified data format conversion, and then output to a file, device, or standard output.

Parameter Description:

  • if = file name: Enter the file name, the default is standard input. Which specifies the source file.
  • of = file name: output file name defaults to standard output. Which specifies the destination file.
  • ibs = bytes: bytes bytes once read that specify a block size of bytes bytes.
    obs = bytes: one output bytes bytes, which specifies a block size of bytes bytes.
    bs = bytes: set both read / output block size bytes bytes.
  • cbs = bytes: bytes bytes of a conversion, the conversion specified buffer size.
  • skip = blocks: blocks Skip blocks from the beginning of the input file and then start copying.
  • seek = blocks: blocks Skip blocks from the beginning of the output file and then starts copying.
  • count = blocks: copy only blocks blocks, the block size is equal to the number of bytes specified ibs.
  • conv = <keyword> keyword can have the following 11 types:
    • conversion: convert file with the specified parameters.
    • ascii: ebcdic converted to ascii
    • ebcdic: convert ascii to ebcdic
    • ibm: convert ascii to alternate ebcdic
    • block: each line is converted to a length of cbs, less partially filled with spaces
    • unblock: make the length of each line are cbs, less partially filled with spaces
    • lcase: uppercase characters converted to lowercase
    • ucase: lowercase characters converted to uppercase
    • swab: swap each pair of input bytes
    • noerror: Error does not stop
    • notrunc: do not truncate the output file
    • sync: The Pad every input block to ibs bytes, less than some empty (NUL) character filled.
  • --help: Display help information
  • --version: display version information

Examples

Under Linux make a boot disk, use the following command:

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

The testfile file all uppercase letters of the alphabet, and then turn become testfile_1 file, use the following command at a command prompt:

dd if=testfile_2 of=testfile_1 conv=ucase 

Wherein the content is testfile_2:

$ 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 as 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中的所有字符都变成了大写字母 

Reads from the standard input string and converts the string to uppercase after, and then output to the standard output device, use the command:

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:

$ dd conv=ucase 
Hello Linux! #输入字符串后按回车键  
HELLO LINUX! #按组合键Ctrl+D退出,转换成大写结果  
记录了0+1 的读入  
记录了0+1 的写出  
13字节(13 B)已复制,12.1558 秒,0.0 KB/s 

Linux command Daquan Linux command Daquan