Some notable parameters:
if=FILE
: read from FILE
instead of stdin
of=FILE
: write to FILE
instead of stdout
bs=BYTES
: bs
is the block size; read and write up to BYTES
bytes at a time (default: 512);count=N
: copy only N input blocksseek=N
: skip N
obs-sized blocks at start of outputskip=N
: skip N
ibs-sized blocks at start of inputdd
dd if=/dev/zero of=/dev/null
)hexdump
)dd
misuse can cause interesting errors:
bs
and count
definition errors can lead to infinite size files
of
definition errors can overwrite endpoints:
So define each parameter carefully, especially if running as root!
You will use:
fread
, fwrite
, etc.) to copy datasignal
on SIGUSR1
) to get status reports-i <file>
: input file (defaults to stdin)-o <file>
: output file (defaults to stdout)-b <size>
: block size, the number of bytes copied at a time (defaults to 512)-c <count>
: total number of blocks copied (defaults to the entire file)-p <count>
: number of blocks to skip at the start of the input file (defaults to 0)-k <count>
: number of blocks to skip at the start of the output file (defaults to 0)getopt()
getopt(argc, argv, "i:o:b:c:p:k:")
./dd -i input_file -o output_file -b 256 -c 1
input_file
to offset 0 of output_file