Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
edit file with dd ?!?!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
jsosic
Guru
Guru


Joined: 02 Aug 2004
Posts: 510
Location: Split (Croatia)

PostPosted: Thu Jan 29, 2009 10:12 pm    Post subject: edit file with dd ?!?! Reply with quote

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
View user's profile Send private message
Akkara
Bodhisattva
Bodhisattva


Joined: 28 Mar 2006
Posts: 6702
Location: &akkara

PostPosted: Thu Jan 29, 2009 11:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
paulbiz
Guru
Guru


Joined: 01 Feb 2004
Posts: 508
Location: St. Louis, Missouri, USA

PostPosted: Thu Jan 29, 2009 11:21 pm    Post subject: Reply with quote

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" :P
Back to top
View user's profile Send private message
jsosic
Guru
Guru


Joined: 02 Aug 2004
Posts: 510
Location: Split (Croatia)

PostPosted: Thu Jan 29, 2009 11:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum