在 Linux 下,strings 命令用于从二进制文件中提取可打印字符串。如果你想要批量对多个文件使用 strings,常见做法如下:
for 循环for f in *; do
echo "==== $f ===="
strings "$f"
done
只处理二进制文件(更严谨):
for f in *; do
if file "$f" | grep -q "ELF"; then
echo "==== $f ===="
strings "$f"
fi
done
findfind . -type f -exec strings {} \;
给每个文件加文件名:
find . -type f -exec sh -c 'echo "=== $1 ==="; strings "$1"' _ {} \;
mkdir strings_out
for f in *; do
strings "$f" > "strings_out/$f.txt"
done
find . -type f -exec strings {} \; > all_strings.txt
xargs 提高性能find . -type f | xargs -I{} sh -c 'echo "=== {} ==="; strings "{}"'
-n 8:只显示长度 ≥ 8 的字符串-e:指定编码(如 l、b、s)示例:
strings -n 6 binary_file
如果你有具体场景(如:提取固件、分析恶意样本、只提取 URL / IP),可以告诉我,我可以给你更精准的批量脚本。