Dd can read data from the standard input or file, convert data according to the specified format, and then output to the file, device, or standard output.
Parameter description:
- If = File name: Enter the file name. The default value is standard input. Specifies the source file.
- Of = File name: name of the output file. The default value is standard output. Specifies the target file.
- Ibs = bytes: read bytes at a time, that is, specify a block size as bytes.
Obs = bytes: outputs bytes at a time, that is, specify a block size as bytes.
Bs = bytes: set the size of the read/output block to bytes at the same time.
- Cbs = bytes: bytes are converted at a time, that is, the size of the conversion buffer.
- Skip = blocks: the blocks are skipped from the beginning of the input file and then copied.
- Seek = blocks: the blocks are skipped from the beginning of the output file and then copied.
- Count = blocks: copy only blocks. The block size is equal to the number of bytes specified by ibs.
- Conv = <keyword>. There are 11 types of keywords:
- Conversion: convert the file with the specified parameter.
- Ascii: convert ebcdic to ascii
- Ebcdic: convert ascii to ebcdic
- Ibm: convert ascii to alternate ebcdic
- Block: converts each row to the length of cbs. Spaces are used to fill the remaining parts.
- Unblock: the length of each row is cbs, and the remaining part is filled with spaces.
- Lcase: converts uppercase to lowercase.
- Ucase: converts lowercase to uppercase.
- Swab: swap each pair of input bytes
- Noerror: do not stop when an error occurs
- Notrunc: the output file is not truncated.
- Sync: fill each input block into ibs bytes, and fill the remaining part with null (NUL) characters.
- -- Help: displays help information.
- -- Version: displays version information.
Instance
To create a boot disk in Linux, run the following command:
Dd if = boot. img of =/dev/fd0 bs = 1440 k
Convert all English letters in the testfile file into uppercase letters and convert them to the testfile_1 file. Run the following command at the command prompt:
Dd if = testfile_2 of = testfile_1 conv = ucase
The content of testfile_2 is:
$ Cat testfile_2 # content of 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 content of testfile_1 is as follows:
$ Dd if = testfile_2 of = testfile_1 conv = ucase # Using the dd command, the case-sensitivity conversion records the read from 0 + 1.
Records the write records of 0 + 1
95 bytes (95 B) replicated, 0.000131446 seconds, 723 KB/s
Cmd @ hdd-desktop :~ $ Cat testfile_1 # view the converted content of testfile_1
Hello linux!
Linux is a free UNIX-TYPE opterating system.
This is a linux testfile!
All characters in linux test # testfile_2 are converted into uppercase letters.
The standard input device reads the string, converts it to uppercase, and then outputs it to the standard output device. The command used is:
Dd conv = ucase
Enter the preceding command, press enter, enter the string, press enter, and press Ctrl + D to exit. The following result is displayed:
$ Dd conv = ucase
Hello Linux! # Enter a string and press enter
Hello linux! # Press the combination key Ctrl + D to exit and convert to the big write result
Read records of 0 + 1
Records the write records of 0 + 1
13 bytes (13 B) copied, 12.1558 seconds, 0.0 KB/s