linuxscriptinghexdump

Convert binary data to hexadecimal in a shell script


I want to convert binary data to hexadecimal, just that, no fancy formatting and all. hexdump seems too clever, and it "overformats" for me. I want to take x bytes from the /dev/random and pass them on as hexadecimal.

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).


Solution

  • Perhaps use xxd:

    % xxd -l 16 -p /dev/random
    193f6c54814f0576bc27d51ab39081dc