Many command line tools are written with an ancient 80×25 terminal size in mind and as such their output is often limited (at least, for a current standard). This is quite amazing that a concept of writing tools destined for such a small terminal is so omnipresent given the fact high resolution computer screens, as well as dual- and multi- monitor setups are now such a common thing.
With this in mind a few years ago I coded a simple hex dump tool which I now use quite often – it gives me a better output than a typical hexdump, and… it was a fun exercise to do. The script is written in perl, fully portable (no dependencies) and… it can for sure be a) buggy b) improved in many ways – use at your own risk 🙂
The idea that I came with was based on a large amount of unused space I have observed on my terminal (one that I use on Windows). It is typically at least 140×50 and even more, when needed. As such, the 80 columns used by the standard hex dump tool leaves an empty space of at least 70 characters…
Let’s have a look at cygwin’s hexdump ran in a canonical mode:
I had an idea that this gap could be utilized to present more data. So, my script prints the output similar to the canonical output of hexdump, plus a bonus. The bonus includes:
- the data decimal offset
- extracted strings (both ANSI and wide) that start within the current line
The output looks like this:
You can immediately copy many of the strings to clipboard w/o using strings tool.
This is how to run the script:
perl hex.pl <filename> perl hex.pl -s <filename> perl hex.pl -S <filename> where: -s - extract strings -S - extract strings, and skip output lines w/o strings
You can download the script here.
If you find any bugs or run into any issue, please let me know.