在Shell脚本中将二进制数据转换为十六进制 [英] Convert binary data to hexadecimal in a shell script
本文介绍了在Shell脚本中将二进制数据转换为十六进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将二进制数据转换为十六进制,仅此而已,不要花哨的格式. hexdump
似乎太聪明了,它对我来说过度格式化".我想从/dev/random中获取x个字节,然后将它们以十六进制形式传递.
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.
最好只使用标准的Linux工具,这样就不必在每台机器上安装它(有很多).
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).
推荐答案
也许使用 xxd
:
% xxd -l 16 -p /dev/random
193f6c54814f0576bc27d51ab39081dc
这篇关于在Shell脚本中将二进制数据转换为十六进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文