View previous topic :: View next topic |
Author |
Message |
jsosic Guru
Joined: 02 Aug 2004 Posts: 510 Location: Split (Croatia)
|
Posted: Thu Jan 29, 2009 10:12 pm Post subject: edit file with dd ?!?! |
|
|
Hi guys!
How to just edit portion of file with a 'dd' command? I mean, look at this: Code: | % dd if=/dev/urandom of=file bs=512 count=10240
% ls -alh file
-rw-r--r-- 1 jsosic users 5.0M 2009-01-29 23:06 file
% dd if=/dev/urandom of=file bs=512 count=1024 seek=1024
1024+0 records in
1024+0 records out
524288 bytes (524 kB) copied, 0.309451 s, 1.7 MB/s
% ls -alh file
-rw-r--r-- 1 jsosic users 1.0M 2009-01-29 23:06 file |
Why is dd simply overwriting file? I know it operates on raw data, but how can I trick it into overwriting just a part of my file... _________________ I avenge with darkness, the blood is the life
The Order of the Dragon, I feed on human life |
|
Back to top |
|
|
Akkara Bodhisattva
Joined: 28 Mar 2006 Posts: 6702 Location: &akkara
|
Posted: Thu Jan 29, 2009 11:14 pm Post subject: |
|
|
You need to use the conv=notrunc option (see man dd).
Note that for that to work, dd itself must open the output file, using of=..., as you have done. Shell I/O redirection woun't work since the shell opens those files. |
|
Back to top |
|
|
paulbiz Guru
Joined: 01 Feb 2004 Posts: 508 Location: St. Louis, Missouri, USA
|
Posted: Thu Jan 29, 2009 11:21 pm Post subject: |
|
|
try "conv=notrunc"
edit: you beat me I had reply typed before you, but then someone came to me and had a conversation before i clicked "submit" |
|
Back to top |
|
|
jsosic Guru
Joined: 02 Aug 2004 Posts: 510 Location: Split (Croatia)
|
Posted: Thu Jan 29, 2009 11:30 pm Post subject: |
|
|
Thanks to you both! _________________ I avenge with darkness, the blood is the life
The Order of the Dragon, I feed on human life |
|
Back to top |
|
|
|