Code Monkey home page Code Monkey logo

bprint's Introduction

Overview

hexdump's format string is hard to use IMO, and the shipped version on Debian 6 and OS X doesn't support 64-bit integer. So I created this little tool in Go to replace hexdump for my own need.

Limitations:

  • Does not support floating point number and string
  • Does not have special print specifier to control where to print offset, etc.
  • Others features that I do not use

Usage

In bprint, the binary data specification and how the they are going to be printed is specified separately using the -e and -p option.

  • -e specifies binary field. Using the same syntax as Ruby's Array.unpack.
    • c, s, l, q stands for signed 8,16,32,64-bit integer
    • C, S, L, Q stands for unsigned 8,16,32,64-bit integer
    • A number following the type specifier repeats that specifier. For example, c4 is equivalent to cccc
  • -p specifies how to print the binary data. It uses C printf style field specifier
    • %c, %d, %x, %o are supported, size and signess information is implicit from the binary field information
    • if not specified, defaults to %02x for each binary field
    • field can be followed by an optional seperator and count to repeat. For example, %2d-3# is eqivalent to %2d-%2d-%2d
  • -f read binary and print format from file. 1st line for binary format, 2nd line for print format (optional). Command line option overrides spec in file
  • -o print offset at the left most column
  • -c print how many record has been read (right after offset column)
  • --version print version information

Example

Suppose each record in the binary file contains 2 byte and 1 64-bit integer, here's invocation to print it's content:

bprint -e 'c2q' -p '%x %d2#' bindata

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.