在Unix Shell中,如何通过机器 - ordian顺序从十六进制字符串转换为stdout字节
我想运行类似的命令:
# echo 00: 0123456789abcdef | xxd -r | od -tx1
0000000 01 23 45 67 89 ab cd ef
0000010
也就是说,我想输入一个十六进制字符串,并将其转换为stdout上的字节。但是,我希望它尊重我正在使用的机器的字节订单,这是小末日。这是证据:
# lscpu | grep Byte.Order
Byte Order: Little Endian
所以,如果我的机器是大型的,我希望它能像上面一样工作。但是由于不是,所以我想看到:
# <something different here> | od -tx1
0000000 ef cd ab 89 67 45 23 01
0000010
现在,XXD对于Little Endianess具有“ -e”选项。但是1)我想要机器端,因为我想要在大型或小的机器上使用的东西,而2)“ -e”无论如何都不支持“ -r”。
谢谢!
I'd like to run a command similar to:
# echo 00: 0123456789abcdef | xxd -r | od -tx1
0000000 01 23 45 67 89 ab cd ef
0000010
That is, I'd like to input a hex string and have it converted to bytes on stdout. However, I'd like it to respect byte order of the machine I'm on, which is little endian. Here's the proof:
# lscpu | grep Byte.Order
Byte Order: Little Endian
So, I'd like it to work as above if my machine was big-endian. But since it isn't, I'd like to see:
# <something different here> | od -tx1
0000000 ef cd ab 89 67 45 23 01
0000010
Now, xxd has a "-e" option for little endianess. But 1) I want machine endianess, because I'd like something that works on big or little endian machines, and 2) "-e" isn't support with "-r" anyway.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那呢 -
根据
MAN XXD
:What about this —
According to
man xxd
: