Byte Out (bo) program

Discussion in 'Command Line' started by Govand Sinjari, Aug 19, 2014.

  1. Govand Sinjari

    Govand Sinjari New Member

    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    3
    Hi,

    Not sure if there is command line can output a specific number of bytes from a file in specific format?

    I have written a tiny program in C for that, for example if you run ./bo 10 x file , it will output first 10 bytes of the file in Hex. The program can use any format specifier of printf like x, c, d, o, s, f, etc.


    If there is no such command, I want to submitted to public domain, will it be possible to add it to linux commands? how?

    I have compiled the command for Mac and Kali, it is attached

    Attached Files:

    DevynCJohnson likes this.
  2. unixfish

    unixfish Member

    Messages:
    44
    Likes Received:
    25
    Trophy Points:
    18
    I appreciate items like this when I need to do something repeatedly.

    I don't know of a "single" command to do this - there may be one.

    However,

    head -n1 file.txt | cut -b-6 | od -x
    or
    head -n1 file.txt | cut -c-6 | od -x

    would do the same thing. This approach also lets you choose what line (use head and tail), and you can still choose character count and format. You could throw this into a shell script and pass variables to do the same thing.

    Cool little utility though. I have a bunch of "special purpose" programs and scripts for stuff I need to do all the time, so I understand the need to create things like this.
    Govand Sinjari and DevynCJohnson like this.
  3. Govand Sinjari

    Govand Sinjari New Member

    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    3
    Thanks unixfish, very useful commands, I knew what each one does but never used it like that.

Share This Page