Given this file
$ cat hello.txt
hello doge world
I would like to remove a range of bytes to end up with this
$ cat hello.txt
heorld
I would like to do this with dd
if possible. The reason is because I am
already using dd
to overwrite bytes in this manner
printf '\x5E' | dd conv=notrunc of=hello.txt bs=1 seek=$((0xE))
I prefer to write back to the same file, but a different output file would be
okay.
Best Answer
It is a matter of specifying blocksize, count, and skip:
The above uses three invocations of
dd
. The first gets the first two charactershe
. The second skips to the end ofhello
and copies the space which follows. The third skips into the last wordworld
copying all but its first character.This was done with GNU
dd
but BSDdd
looks like it should work also.