Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Linux (Kubuntu) system with a large (~20Gb) file which I would like to mess with. Specifically, I want to copy the entire contents of another large file (~12Gb) to the middle of this file, and keep the bits of the file which are not overwritten.

This is what I want to happen, with the text between the pipes representing file contents:


outfile: |abcdefghijklmnopqrstuvwxyz|
infile:  |123456789|


outfile: |abcdef123456789pqrstuvwxyz|
(infile is here ^^^^^^^^^)

I tried this:

dd if=infile of=outfile seek=162

(162 is the number of sectors I want to offset by in outfile)

But this is what happened:

outfile: |abcdef123456789|
(missing part of outfile ^)

What is the best way to do this?

share|improve this question
up vote 5 down vote accepted

You need to specify conv=notrunc to dd. From the manpage

Any regular output file is truncated unless the notrunc conversion value is specified. If an initial portion of the output file is seeked past (see the oseek operand), the output file is trun- cated at that point.

share|improve this answer
Works great, thank you so much! I read dd --help but didn't try the man page. Stupid me... – marcusw Jan 15 '10 at 21:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .