This question came to me a couple of times before, now in response to the question Loop through binary data chunks from stdin in Bash Answers given in https://stackoverflow.com/questions/993434/what-language-is-to-binary-as-perl-is-to-text were also not satisfactory.
I'm looking for a scripting environment suited specifically to handle I/O with binary files. I know I can use one of the fully-fledged programming languages (c/Python/...) but they have an enormous initialization and coding overhead (allocation and fread/fwrite in c, bitstrings in Python...) not to mention they are less suited for scripting (calling other applications from it). Perl is no better with its unpack
functions, string-oriented operation and goofy syntax.
Something like od
, but as a language.
What I expect:
- set or change endianness with a single switch/command.
- simple specification of requested type (something like extending bash
read var
withint32 var
,float var
etc.). - handling of binary through pipes, skipping of specified number of bytes.
- standard scripting flow control (for/if/...) that we are used to.
I'd like to process raw data (photography, scientific data, unknown and poorly documented formats) with the same ease and insight that you get when inspecting ASCII files. I'm using c
now, but it's not optimal for ad-hoc scripting, and can't be interactive.
Does anyone know a tool like that? No clicky GUI software, please, it needs to work over ssh, from other scripts and so on. "Does not exist" is an acceptable, but depressing answer.
chain = ls["-a"] | grep["-v", "\\.py"] | wc["-l"]; chain()
Have you looked at that?perl
'sunpack
(ᵔᴥᵔ)