温馨提示×

linux strings结果怎么保存

小樊
40
2026-09-23 18:34:57
栏目: 智能运维

在 Linux 下,strings 命令用于从二进制文件中提取可打印字符串。要把结果保存下来,常见方法如下:


1. 使用输出重定向(最常用)

strings file.bin > output.txt
  • >:覆盖写入 output.txt
  • >>:追加写入 output.txt

示例:

strings /bin/ls > ls_strings.txt

2. 同时输出到屏幕和文件(tee)

strings file.bin | tee output.txt

如果要以 追加 方式保存:

strings file.bin | tee -a output.txt

3. 指定编码或最小值长度并保存

strings -n 6 file.bin > output.txt
  • -n 6:只显示长度 ≥ 6 的字符串

4. 处理多个文件

strings file1 file2 file3 > all_strings.txt

或批量处理:

for f in *.bin; do
    strings "$f" >> all_strings.txt
done

5. 过滤后保存(结合 grep)

strings file.bin | grep "password" > passwords.txt

如果你是想:

  • 保存为特定格式(CSV / JSON)
  • 在脚本中自动保存
  • 分析 ELF / 固件 / 内存 dump

可以告诉我具体场景,我可以给你更合适的命令。

0 踩