在 Ubuntu 下,strings 命令常用于从二进制文件中提取可打印字符串。如果你想批量对多个文件使用 strings,常见做法如下:
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
find . -type f -exec strings {} \;
find . -type f -exec sh -c 'echo "=== $1 ==="; strings "$1"' _ {} \;
find . -type f -exec sh -c 'file "$1" | grep -q ELF && { 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
find . -type f -print0 | xargs -0 strings
strings -n 6 file # 至少 6 个字符
strings -e l file # 16-bit little endian
strings -a file # 扫描整个文件
如果你能说明:
我可以给你更精确的批量脚本。