Comments (2)
So I did a bit more digging on how other tools do it.
With xxd, it supports it by the -r
option:
-r | -revert
Reverse operation: convert (or patch) hex dump into binary. If not writing to stdout, xxd writes into its output file without truncating it. Use the combination -r -p to read plain hexadecimal
dumps without line number information and without a particular column layout. Additional whitespace and line breaks are allowed anywhere. Use the combination -r -b to read a bits dump instead
of a hex dump.
Basically the expectation is that you feed the output of a previous xxd
command into xxd -r
to revert back to the original file. Formatting options given to the first invocation must be given to the second, for example:
xxd input | xxd -r
xxd -b input | xxd -br
Hexdump on the other hand has a very powerful output formatting syntax. It provides a way to split output into groups of bytes, and consume/format some number of groups. This is how you'd output the raw binary:
hexdump input -ve '1/1 "%c"' # Number of groups / Number of bytes
hexdump input -ve '"%c"' # 1/1 elided
Hexdump output formatting is powerful (see some examples in a Suse blog post), though it seems like it'd be more practical to write a python script than a hexdump format file these days for most uses.
I think having a --raw
output would be the simplest codewise. It'd just require bailing out early and copying the reader to stdout after skip/take. I could see an argument for adding a custom output format option similar to hexdump's (though ideally simplified). In that case it'd make sense to collect some usecases that Hexyl would want to support and design towards that.
from hexyl.
That sounds like an interesting idea! I think it would be a nice feature to have, if it can be cleanly integrated into the code base.
We should maybe also research what other tools do (hexdump, xxd). I think they provide options to turn their output back into binary? which might be even more powerful. Because you can build pipelines and integrate other tools as well.
from hexyl.
Related Issues (20)
- Is there a cheat sheet anywhere telling what color correlates to category of byte? HOT 3
- Add support for the NO_COLOR environment variable HOT 4
- Regression: broken pipe error
- Make --panels=auto the new default? HOT 3
- hexyl should not fail if `--panels=auto` is used and output is not a TTY
- Identical lines not squeezed HOT 3
- hexyl -C does the inverse of hexdump -C HOT 1
- Request: publish source tar with generated manpage HOT 3
- Support for different code pages / character tables
- Incorrect output when reading from terminal HOT 2
- Feature request: Ship as a crate HOT 3
- `hexyl /dev/zero` hangs HOT 6
- Display some non-printable characters like `bat --show-all` HOT 5
- Feature request: Comodore prg mode HOT 1
- CI artifact names conflict HOT 2
- Provide Statically Compiled Binaries for (aarch64|arm64) Linux HOT 1
- Customize colors
- Completions for fish shell HOT 1
- is there a way to open disk devices in windows? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hexyl.