在 Ubuntu 下,“strings”通常指的是:
strings 命令(从二进制/文件中提取可打印字符串).po / .pot 文件)下面按常见场景给你几种批量处理方法。
strings 命令for f in /path/to/files/*; do
strings "$f" > "$f.txt"
done
find /path/to/dir -type f -exec strings {} \; > all_strings.txt
find . -type f -name "*.so" -exec strings {} \; > so_strings.txt
find . -type f -exec strings {} \; | sort | uniq > strings_uniq.txt
如果你是想批量查找字符串内容:
grep -rl "keyword" /path/to/dir
或递归并显示行号:
grep -rn "keyword" /path/to/dir
如果你是做软件翻译:
find . -name "*.c" -o -name "*.cpp" | xargs xgettext -o messages.pot
for po in *.po; do
msgmerge --update "$po" messages.pot
done
for po in *.po; do
msgfmt "$po" -o "${po%.po}.mo"
done
find . -type f -exec sed -i 's/old_string/new_string/g' {} +
⚠️ 修改前建议先备份:
cp -r project project.bak
find . -type f | parallel strings {} \> {}.strings.txt
(需安装 parallel)
如果你能具体说明:
我可以直接给你一条最合适的命令。