[lug] Random access from the shell
Sean Reifschneider
jafo at tummy.com
Wed Nov 12 17:55:58 MST 2008
Jeffrey Haemer wrote:
> ## now, an example
> echo hello, world > foo # a test file to overwrite
> seek foo 7
> write "Jeff!"
> seek foo 0
> write "Howdy"
That's a cute recipe, but I think I'd use dd to do something like that:
guin:/tmp$ echo 'hello world' >foo
guin:/tmp$ printf 'Sean!' | dd conv=notrunc of=foo bs=1 seek=6
5+0 records in
5+0 records out
5 bytes (5 B) copied, 8.3809e-05 s, 59.7 kB/s
guin:/tmp$ printf Howdy | dd conv=notrunc of=foo bs=1 seek=0
5+0 records in
5+0 records out
5 bytes (5 B) copied, 8.2413e-05 s, 60.7 kB/s
guin:/tmp$ cat foo
Howdy Sean!
Sean
--
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability
More information about the LUG
mailing list