使用单个命令从二进制转换为 ascii 十六进制

To use a single command in converting from binary to ascii hex

我正在将二进制数据转换为十六进制数据,并在连续流的头部查看此十六进制数据。 我 运行 下面的转换来自

echo "ibase=2;obase=10000;$(echo `sed '1q;d' /Users/masi/Dropbox/123/r3.raw`)" \ 
                                                                               \ 
| bc                                                                           \
                                                                               \  
| head

然后我得到

(standard_in) 1: illegal character: H

如此错误的数据类型。

如何通过一条命令高效地将二进制文件转换为二进制 ascii 文件?

我 运行 以下代码基于 Wintermute 的评论

hexdump -e '/4 "%08x\n"' r3.raw 

例如,head r3.raw | hexdump -e '/4 "%08x\n" 给出

ffffffff
555eea57
...