feel a bit stupid asking this (sounds as basics) but can't find an answer elsewhere. I want to convert binary data to hex, just that, no fancy formatting and all. hexdump
seems too clever, it "overformats" for me. I want to take x bytes from the /dev/random and pass them on as hex.
Preferably I'd like to use only standard linux tools, so that I don't need to install it on every machine (there are many)
Perhaps you could write your own small tool in C, and compile it on-the-fly:
And then feed it from the standard input:
You can even embed this small C program in a shell script using the heredoc syntax.
This three commands will print the same (0102030405060708090a0b0c):
Given that
n=12
and$a
is the byte values from 1 to 26:That could be used to get
$n
random byte values in each program: