Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

Before:

outfile: |abcdefghijklmnopqrstuvwxyz|
infile:  |123456789|

After:

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

1 Answer 1

up vote 4 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.