The following example first prepares an input file and an output file, then copies a portion of the input into a portion of the output file.
echo "IGNORE:My Dear Friend:IGNORE" > infile
echo "Keep this, OVERWRITE THIS, keep this." > outfile
dd status=none \
The arguments to dd are:
status=none Don't output final statistics as dd usually does - would disturb the demo
bs=1 All the following numbers are counts of bytes -- i.e., 1-byte blocks.
if=infile The input file
skip=7 Ignore the first 7 bytes of input (skip "IGNORE:")
count=14 Transfer 14 bytes from input to output
of=outfile What file to write into
conv=notrunc Don't delete old contents of the output file before writing.
seek=11 Don't overwrite the first 11 bytes of the output file
i.e., leave them in place and start writing after them
The result of running the script is:
IGNORE:My Dear Friend:IGNORE
Keep this, OVERWRITE THIS, keep this.
Keep this, My Dear Friend, keep this.
What would happen if you exchanged the values of 'skip' and 'seek'?
dd would copy the wrong part of the input and overwrite the wrong part of the output file:
Keep thear Friend:IGNTHIS, keep this.