温馨提示×

linux strings输出如何保存

小樊
38
2026-09-29 14:51:45
栏目: 智能运维

在 Linux 中,strings 命令用于从二进制文件中提取可打印字符串。如果你想把 strings 的输出保存下来,通常有以下几种方式:


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

strings file.bin > output.txt
  • > 表示覆盖写入 output.txt
  • 如果文件已存在,会被清空再写入

追加写入:

strings file.bin >> output.txt

2. 同时查看并保存(tee)

strings file.bin | tee output.txt
  • 终端会显示内容
  • 同时写入 output.txt

追加:

strings file.bin | tee -a output.txt

3. 保存带行号的输出

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

4. 从多个文件提取并保存

strings *.bin > all_strings.txt

5. 结合其他命令处理后再保存

例如只提取包含 “password” 的字符串:

strings file.bin | grep password > result.txt

6. 二进制偏移信息一起保存

strings -a -t x file.bin > output.txt
  • -t x:显示十六进制偏移
  • -a:扫描整个文件

如果你有具体场景(比如想保存哪类字符串、是否要过滤、是否要批量处理),可以告诉我,我可以给你更精确的命令。

0 踩