在外壳程序脚本中将二进制数据转换为十六进制? [英] convert binary data to hex in shell script?
本文介绍了在外壳程序脚本中将二进制数据转换为十六进制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问这个问题(听起来很基础)有点愚蠢,但是在其他地方找不到答案.我想将二进制数据转换为十六进制,仅此而已,不要花哨的格式化等等. hexdump
似乎太聪明了,对我来说它过格式".我想从/dev/random中提取x个字节,然后将它们作为十六进制传递.
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.
最好只使用标准的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
这篇关于在外壳程序脚本中将二进制数据转换为十六进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文