在 Debian 系统里,“strings”通常指两件事之一:
strings 命令:从二进制/数据文件中提取可打印字符串gettext 的 .po / .pot 国际化字符串:Debian 软件包本地化用下面分别说明批量处理方法。
strings 命令(提取二进制中的字符串)find ./bin -type f -exec strings {} \; > all_strings.txt
find . -type f -exec sh -c '
file "$1" | grep -q "ELF" && strings "$1"
' _ {} \; > elf_strings.txt
for f in /usr/bin/*; do
echo "==== $f ===="
strings "$f"
done > strings_report.txt
apt install parallel
find . -type f | parallel strings > all.txt
.po / .pot).po 文件中的 msgid / msgstrfor po in *.po; do
echo "== $po =="
msgattrib --no-obsolete "$po"
done
.pot 模板到 .pofor po in *.po; do
msgmerge --update "$po" template.pot
done
.po 为 .mofor po in *.po; do
msgfmt "$po" -o "${po%.po}.mo"
done
for po in *.po; do
echo "$po: $(msgfmt --statistics "$po" 2>&1)"
done
如果你是在 Debian 打包:
# 自动提取字符串
dpkg-buildpackage
# 或手动
dh_make
debchange
通常不需要手动批量处理 strings,debhelper 会自动调用 xgettext / intltool。
提取某软件所有二进制字符串并去重:
find /opt/app -type f -exec file {} \; |
grep ELF | cut -d: -f1 |
xargs strings |
sort -u > app_strings.txt
如果你能具体说明:
我可以给你更精准的脚本。