dd 中文man頁面
名字
dd - 轉(zhuǎn)換和拷貝文件
摘要
dd [--help] [--version] [if=file] [of=file] [ibs=bytes] [obs=bytes] [bs=bytes] [cbs=bytes] [skip=blocks] [seek=blocks] [count=blocks] [conv={ascii, ebcdic, ibm, block, unblock, lcase, ucase, swab, noerror, notrunc, sync}]
描述
當(dāng)進(jìn)行非強(qiáng)制的轉(zhuǎn)換的時(shí)候,使用指定的輸入和輸出塊大小拷貝文件(默認(rèn)是從標(biāo)準(zhǔn)輸入到標(biāo)準(zhǔn)輸出。
它每次從輸入讀取指定大小的一個(gè)塊(默認(rèn)是512字節(jié))。如果使用 bs=bytes 選項(xiàng),并且沒有轉(zhuǎn)換,除了指定 sync, noerror, 或 notrunc 之外, 那么dd將把全部讀到的數(shù)據(jù)(可以比請(qǐng)求讀的少)寫到獨(dú)立的輸出塊去。 這個(gè)輸出塊的長度和讀到的數(shù)據(jù)完全一樣,除非指定使用 sync(同步) 轉(zhuǎn)換,那樣的話,數(shù)據(jù)結(jié)尾處將追加NUL字符(或空格,見下)。
其他情況下,輸入的時(shí)候每次讀一個(gè)塊,然后處理,并將輸出結(jié)果收集起來,***寫到指定大小的數(shù)據(jù)塊中去。最終的輸出塊可能會(huì)比指定的大小短一些。
數(shù)字值選項(xiàng)(以字節(jié)或塊為單位)后面可以跟一個(gè)乘數(shù): k=1024,b=512,w=2,c=1(w和c是GNU擴(kuò)展語法。***別使用w,因?yàn)樵趕ystem V中,它表示2,在4.2 BSD中,它表示4)。兩個(gè)或更多的數(shù)值表達(dá)式可以通過“x”乘起來。 GEU fileutils 4.0并且允許在數(shù)據(jù)塊大小的敘述中使用下列乘法后綴(用bs=,cbs=,obs=):M=1048576,G=1073741824,同理可得T,P,E,Z,Y。D后綴表示數(shù)值是以十進(jìn)制表示的:kD=1000 MD=1000000 GD=1000000000等等。(注意,在ls、df、du命令中,M等標(biāo)記的大小是由環(huán)境變量確定的,而在DD中,它的值是固定的。)
選項(xiàng)
- if=file
- 從 file 中讀而不是標(biāo)準(zhǔn)輸入。
- of=file
- 寫到 file 里去而不是標(biāo)準(zhǔn)輸出。除非指定 conv=notrunc ,否則, dd 將把 file 截為O字節(jié)(或由 seek= 選項(xiàng)指定的大小)
- ibs=bytes
- 一次讀 bytes 字節(jié)。默認(rèn)是512。
- obs=bytes
- 一次寫 bytes 字節(jié)。默認(rèn)是512。
- bs=bytes
- 一次讀和寫 bytes 字節(jié)。這將覆蓋 ibs 和 obs 設(shè)定的值(并且,設(shè)定 bs 不等于同時(shí)將 ibs 和 obs 設(shè)為同一個(gè)值,至少在只使用 sync, noerror 或 notrunc 轉(zhuǎn)換時(shí)是這樣的。因?yàn)閎s規(guī)定,每個(gè)輸入塊都應(yīng)作為單獨(dú)的數(shù)據(jù)塊拷貝到輸出,而不把較短的塊組合到一起)。
- cbs=bytes
- 為 block 轉(zhuǎn)換和 unblock 轉(zhuǎn)換指定轉(zhuǎn)換塊的大小。
- skip=blocks
- 在拷貝之前,跳過輸入文件的前 blocks 塊,每塊大小為 ibs-byte 字節(jié)。
- seek=blocks
- 在拷貝之前,跳過輸出文件的前 blocks 塊,每塊大小為 obs-byte 字節(jié)。
- count=blocks
- 只拷貝輸入文件的前 blocks 塊(每塊的大小為 ibs-byte 字節(jié)),而不是全部內(nèi)容,直到文件末尾。
- conv=轉(zhuǎn)換[,轉(zhuǎn)換]...
- 將文件按 轉(zhuǎn)換 參數(shù)指定的方式轉(zhuǎn)換(在“,”兩邊沒有空格)。
-
轉(zhuǎn)換方式包括:
- ascii
- 將EBCDIC轉(zhuǎn)換成ascii。
- ebcdic
- 將ascii轉(zhuǎn)換成ebcdic。
- ibm
- 將ascii轉(zhuǎn)換成alternative ebcdic。
- block
- 每一行輸入,無論長短,輸出都是 cbs 字節(jié),并且其中的“換行”(NEWLINE,即c中的')用空格替換。如有必要,行尾會(huì)填充空格。
- unblock
- 用“換行”替換每個(gè)輸入塊( cbs 字節(jié)大?。┠┪驳目崭?。
- lcase
- 將大寫字母轉(zhuǎn)換成小寫。
- ucase
- 將小寫字母轉(zhuǎn)換成大寫。
- swab
- 交換每對(duì)輸入字節(jié)。如果讀入的字節(jié)數(shù)是奇數(shù),***一個(gè)字節(jié)只是簡單的復(fù)制到輸出(因?yàn)闆]有能跟它交換的字節(jié)了)(POSIX 1003.26,PASC翻譯1003.2 3號(hào)和4號(hào))。
- noerror
- 發(fā)生讀錯(cuò)誤時(shí),繼續(xù)進(jìn)行。
- notrunc
- 不截?cái)噍敵鑫募?
- sync
- 用0填充到每個(gè)輸入塊的末尾,使其大小為 ibs 字節(jié)。
-
GNU標(biāo)準(zhǔn)選項(xiàng)
- --help
- 將用法信息打印到標(biāo)準(zhǔn)輸出,并成功退出。
- --version
- 將版本信息打印到標(biāo)準(zhǔn)輸出,并成功退出。
- --
- 結(jié)束選項(xiàng)列表。
環(huán)境變量
LANG, LC_ALL, LC_CTYPE和LC_MESSAGES具有其通常含義。
遵循標(biāo)準(zhǔn)
POSIX 1003.2
舉例
磁帶機(jī)通常不能接受任意大小的數(shù)據(jù)塊,當(dāng)***一個(gè)數(shù)據(jù)片段不能充滿整個(gè)塊時(shí), dd 將出現(xiàn)I/O錯(cuò)誤。用'dd if=myfile of=/dev/mytape conv=sync' 就可以使全部內(nèi)容存到磁帶上。當(dāng)然,這樣做,把文件從磁帶上讀回時(shí)回產(chǎn)生一個(gè)稍大些的文件,因?yàn)槠湮膊刻畛淞艘恍㎞UL(空字符)。
注
本手冊(cè)頁描述了fileutils-4.0軟件包中的 dd 命令。其他版本的dd會(huì)與此稍有不同。有關(guān)更正和補(bǔ)充可以發(fā)帖到中國linux 論壇-man手冊(cè)版。報(bào)告程序中的錯(cuò)誤,請(qǐng)給 fileutils-bugs2gnu.ai.wit.edu 發(fā)郵件。
#p#
NAME
dd - convert and copy a file
SYNOPSIS
dd [OPTION]...
DESCRIPTION
Copy a file, converting and formatting according to the options.
- bs=BYTES
- force ibs=BYTES and obs=BYTES
- cbs=BYTES
- convert BYTES bytes at a time
- conv=KEYWORDS
- convert the file as per the comma separated keyword list
- count=BLOCKS
- copy only BLOCKS input blocks
- ibs=BYTES
- read BYTES bytes at a time
- if=FILE
- read from FILE instead of stdin
- obs=BYTES
- write BYTES bytes at a time
- of=FILE
- write to FILE instead of stdout
- seek=BLOCKS
- skip BLOCKS obs-sized blocks at start of output
- skip=BLOCKS
- skip BLOCKS ibs-sized blocks at start of input
- --help
- display this help and exit
- --version
- output version information and exit
BLOCKS and BYTES may be followed by the following multiplicative suffixes: xM M, c 1, w 2, b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y. Each KEYWORD may be:
- ascii
- from EBCDIC to ASCII
- ebcdic
- from ASCII to EBCDIC
- ibm
- from ASCII to alternated EBCDIC
- block
- pad newline-terminated records with spaces to cbs-size
- unblock
- replace trailing spaces in cbs-size records with newline
- lcase
- change upper case to lower case
- notrunc
- do not truncate the output file
- ucase
- change lower case to upper case
- swab
- swap every pair of input bytes
- noerror
- continue after read errors
- sync
- pad every input block with NULs to ibs-size; when used
- with block or unblock, pad with spaces rather than NULs
Note that sending a SIGUSR1 signal to a running `dd' process makes it print to standard error the number of records read and written so far, then to resume copying.
- $ dd if=/dev/zero of=/dev/null& pid=$!
$ kill -USR1 $pid; sleep 1; kill $pid - 10899206+0 records in 10899206+0 records out
AUTHOR
Written by Paul Rubin, David MacKenzie, and Stuart Kemp.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright © 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
SEE ALSO
The full documentation for dd is maintained as a Texinfo manual. If the info and dd programs are properly installed at your site, the command
- info coreutils dd
should give you access to the complete manual.