在 Debian 系统中,“strings” 通常指两件事之一,取决于你的具体需求:
strings 命令:从二进制文件中提取可打印字符串.po / .pot 字符串:用于翻译的源字符串下面分别说明。
strings 命令(最常见)strings在 Debian / Ubuntu 上,它属于 binutils:
sudo apt update
sudo apt install binutils
从二进制文件中提取字符串:
strings /bin/ls
strings -n 6 filename # 只显示长度 ≥ 6 的字符串
strings -e l filename # 指定编码(l = 16-bit little-endian)
strings -o filename # 显示字符串在文件中的偏移
.so、可执行文件、core dump 中提取strings libfoo.so
strings core
如果你是 Debian 包维护者或开发者,通常说的 “生成 strings” 是指:
从源代码中提取可翻译字符串,生成
.pot文件
sudo apt install gettext autotools-dev
C / C++ 示例:
printf(_("Hello, world!\n"));
xgettext --language=C --keyword=_ --output=messages.pot *.c
很多 Debian 包使用:
make dist
或:
autoreconf -i
./configure
make
配合:
make update-po
生成或更新 .po 文件。
如果是 debconf 模板字符串:
debconf-show <package>
debconf-get-selections
或查看:
/var/lib/dpkg/info/*.templates
.deb 文件中提取dpkg-deb -x package.deb tmp/
strings tmp/usr/bin/foo
或从已安装文件:
dpkg -L package | xargs strings
| 目的 | 方法 |
|---|---|
| 分析二进制 | strings |
| 提取翻译字符串 | xgettext |
| Debian 包翻译 | .po / .pot |
| debconf 字符串 | .templates |
如果你能具体说明:
我可以给你更精确的命令和示例。