在 shell 脚本中将二进制数据转换为十六进制 [英] Convert binary data to hexadecimal in a shell script

查看:74
本文介绍了在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆