Results 1 to 7 of 7

Thread: Quick dd command question

  1. #1
    Join Date
    Jun 2008
    Location
    Atlanta, Georgia, USA
    Posts
    2,429

    Default Quick dd command question

    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!

  2. #2
    ab@novell.com NNTP User

    Default Re: Quick dd command question

    -----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-----

  3. #3
    Join Date
    Jun 2008
    Location
    Atlanta, Georgia, USA
    Posts
    2,429

    Default Re: Quick dd command question

    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!

  4. #4
    ab@novell.com NNTP User

    Default Re: Quick dd command question

    -----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-----

  5. #5
    Join Date
    Jun 2008
    Location
    Atlanta, Georgia, USA
    Posts
    2,429

    Default Re: Quick dd command question

    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.)

  6. #6
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Quick dd command question

    Quote Originally Posted by mingus725 View Post
    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!
    There's more than one way to do it.
    Code:
    tail -c+446 file | head -c66 > extract
    See man head and man tail to get head and tail of all this.

  7. #7
    Join Date
    Jun 2008
    Location
    Atlanta, Georgia, USA
    Posts
    2,429

    Default Re: Quick dd command question

    Outstanding. Thanks, Ken!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •