在 Ubuntu 上执行 strings 命令“没有输出”,通常不是命令坏了,而是目标文件里没有可打印字符串,或用法/参数不对。下面按常见原因逐一说明。
strings empty.txt
如果文件里根本没有 ≥4 个连续可打印字符,strings 默认什么都不输出。
✅ 验证:
echo -n "hello" > a.txt
strings a.txt # 有输出
strings file
只显示 连续 ≥4 个可打印字符 的字符串。
短字符串不会显示:
echo -n "abc" > b.txt
strings b.txt # 无输出
✅ 解决:
strings -n 1 file
strings 对普通文本、压缩包、图片也可能“看起来没东西”。
例如:
strings image.png
可能只有很少内容。
strings
某些版本会等待 stdin,看起来像“卡住 / 没输出”。
✅ 正确:
strings ./a.out
确认文件真实存在:
ls -l file
file file
strings stripped_binary
仍然会有字符串(函数名可能没了,但常量还在)
如果完全没有:
strings -a file # 扫描整个文件
strings -e l file # 16-bit little endian
你可以依次试:
file yourfile
strings -n 1 yourfile
strings -a yourfile
hexdump -C yourfile | head
你可以直接贴:
file 输出)我可以帮你精确判断是哪一种情况。