在 Linux 下批量对多个文件运行 strings,常见做法如下:
for f in *; do
echo "==== $f ===="
strings "$f"
done
只处理普通文件:
for f in *; do
[ -f "$f" ] && strings "$f"
done
find . -type f -exec strings {} \;
每个文件前加文件名:
find . -type f -exec sh -c 'echo "== $1 =="; strings "$1"' _ {} \;
for f in *; do
strings "$f" > "$f.txt"
done
for f in *; do
echo "==== $f ====" >> all_strings.txt
strings "$f" >> all_strings.txt
done
find . -type f | xargs -I{} sh -c 'echo "== {} =="; strings "{}"'
并行加速(谨慎使用):
find . -type f | xargs -P 4 -I{} strings {}
find . -type f -name "*.bin" -exec strings {} \;
strings -n 6 file # 最小长度 6
strings -e l file # 小端 UTF-16
如果你有具体场景(比如 ELF、固件、内存 dump、上万个文件),可以告诉我,我可以给你更合适的批量方案。