linux - hexdump 可以用 ASCII 显示 8 列吗?

标签 linux bash shell hexdump

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

5年前关闭。




Improve this question




我喜欢 'hexdump -C' View ,但我可以用 8 字节行而不是 16 行得到同样的东西吗?我想要包括ascii。

已回答的问题:

hexdump -e '"%08.8_Ax\n"' -e '"%08.8_ax " 8/1 " %02x"' -e '"  |" 8/1 "%_p" "|\n"' bla.bin

感谢@rici (下)这个答案。

请注意竖线前面的两个空格。由于某些奇怪的原因,除了缩进的代码块之外,SO 不会渲染超过 1 个相邻的空格字符。
hexdump -e '"%08.8_Ax\n"' -e '"%08.8_ax " 8/1 " %02x"' -e '"  |" 8/1 "%_p" "|\n"' bla.bin
------------------------------------------------------------^^

最佳答案

阅读 man 文件,您会注意到 -e参数。向下滚动一点,我们到达 format部分。

它的解释有点困惑,但现在我们知道可以格式化 hexdump 的输出。

man 文件的末尾显示了一个示例 -e模仿 -x 的命令命令,非常接近 -C你想模仿的命令!
hexdump -e '"%07.7_ax " 8/2 "%04x " "\n"'
经过一番争论,我们可以得到你想要的结果。
hexdump -e '"%08.8_ax " 8/1 "%02x " "|"16/1 "%_p" "|\n"'
注意:我不知道 "08.8_ax "片段计数正确。

关于linux - hexdump 可以用 ASCII 显示 8 列吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40410298/

相关文章:

c - 查找未运行的网络接口(interface)

linux - 在多个地方定义的规则的 Logrotate 行为

bash重装后找不到ghc?

linux - CMake 找不到 Curses

python - (gclalcli) 错误 : could not create 'build/bdist.linux-x86_64/egg' : Permission denied

linux - 使用搜索和替换清理感染 c3284d 病毒的服务器

python - 在后台时卡住标准输入,在前台时解冻它

linux - shell 脚本中的定时陷阱

c++ - 在 C++ 中执行 shell 命令时强制环境 bash

linux - shell脚本中的变量范围