I need to create an output file consisting of bytes 447-512 (66 bytes) of a 512 byte input file. I’m struggling with the exact dd syntax to do that. Help much appreciated. Thanks!
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
How about:
dd ibs=2 skip=223 count=33 if=./testme
So ibs = block size (two bytes), skip is how many to skip (223 blocks,
which should be 446 bytes), count = 33 (blocks, to read, meaning 66
bytes), if = InFile (source file).
Then use either of=OutFile to write out, or pipe it to less, or write
via STDOUT redirect (>).
Good luck.
mingus725 wrote:
> I need to create an output file consisting of bytes 447-512 (66 bytes)
> of a 512 byte input file. I’m struggling with the exact dd syntax to do
> that. Help much appreciated. Thanks!
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFI0p833s42bA80+9kRAtfnAJ91P6OinXr/jQf900vlAI+64Hp9NQCfUXKA
PXHlxGBYPUU7kpwiLb6721M=
=WaRW
-----END PGP SIGNATURE-----
Thx much for the fast reply. Quick follow-up pls . . .
Is that the same as:
dd if=filein ibs=1 skip=446 count=66 of=fileout
I didn’t follow why defining a block size of 2 bytes in your example.
Thx again!
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Yeah, looks the same. Defining a block size just means saying how big a
“block” is in bytes. I chose two… I believe ‘dd’ performs better (to
an extent) with larger blocks, but it won’t matter in your case since
you’re probably just trying to get the partition table from a drive,
right (vs. getting the entire MBR)? In multi-MB or GB files a 1 byte
block would probably be a huge waste but that’s not the case here.
Good luck.
mingus725 wrote:
> Thx much for the fast reply. Quick follow-up pls . . .
>
> Is that the same as:
>
> dd if=filein ibs=1 skip=446 count=66 of=fileout
>
> I didn’t follow why defining a block size of 2 bytes in your example.
>
> Thx again!
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFI0qPq3s42bA80+9kRAowVAJ9DGsDhONBzHFcT3TkFBML/7QieLwCcCSvI
MrRIblBwaI+SVwarvFHQaZg=
=LRcZ
-----END PGP SIGNATURE-----
You’re exactly right - pulling the table out of the MBR and then concatenating that with a block of (Windows) generic boot loader code. (By the way, I’m doing this because I can’t find the generic IPL code that YaST boot loader writes.)
There’s more than one way to do it.
tail -c+446 file | head -c66 > extract
See man head and man tail to get head and tail of all this.
Outstanding. Thanks, Ken!