dd

dd #

dd - convert and copy a file

Usage #

text
SYNOPSIS
       dd [OPERAND]...
       dd OPTION

DESCRIPTION
       Copy a file, converting and formatting according to the operands.

       bs=BYTES
              read and write up to BYTES bytes at a time (default: 512); overrides ibs and obs

       cbs=BYTES
              convert BYTES bytes at a time

       conv=CONVS
              convert the file as per the comma separated symbol list

       count=N
              copy only N input blocks

       ibs=BYTES
              read up to BYTES bytes at a time (default: 512)

       if=FILE
              read from FILE instead of stdin

       iflag=FLAGS
              read as per the comma separated symbol list

       obs=BYTES
              write BYTES bytes at a time (default: 512)

       of=FILE
              write to FILE instead of stdout

       oflag=FLAGS
              write as per the comma separated symbol list

       seek=N skip N obs-sized blocks at start of output

       skip=N skip N ibs-sized blocks at start of input

       status=LEVEL
              The  LEVEL of information to print to stderr; 'none' suppresses everything but error messages, 'noxfer'
              suppresses the final transfer statistics, 'progress' shows periodic transfer statistics

       N and BYTES may be followed by the following  multiplicative  suffixes:  c=1,  w=2,  b=512,  kB=1000,  K=1024,
       MB=1000*1000,  M=1024*1024,  xM=M,  GB=1000*1000*1000,  G=1024*1024*1024, and so on for T, P, E, Z, Y.  Binary
       prefixes can be used, too: KiB=K, MiB=M, and so on.

Example: 复制文件,保留前30Kib #

bash
# 因为block大小默认是512B,也就是0.5KiB,所以保留30KiB相当于保留60个block。
dd if=SOURCE_FILE of=OUTPUT_FILE count=60

# 也可以:
dd if=SOURCE_FILE of=OUTPUT_FILE bs=1K count=30

Example: 复制文件,忽略前30KiB #

bash
# 因为block大小默认是512B,也就是0.5KiB,所以忽略30KiB相当于跳过60个block。
dd if=SOURCE_FILE of=OUTPUT_FILE skip=60

# 也可以:
dd if=SOURCE_FILE of=OUTPUT_FILE bs=1K skip=30
2024年10月13日