温馨提示×

ubuntu strings输出如何保存

小樊
41
2026-09-03 09:52:53
栏目: 智能运维

在 Ubuntu 中,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 > output.txt
  • -n 6 表示只输出长度 ≥ 6 的字符串

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

strings file1.bin file2.bin > output.txt

或使用通配符:

strings *.so > output.txt

5. 保存时包含文件名(多文件时很有用)

strings -f *.bin > output.txt

输出示例:

a.bin: main
a.bin: printf
b.bin: start

6. 示例:分析 ELF 文件

strings /bin/ls > ls_strings.txt

如果你有更具体的需求,比如:

  • 只提取某些关键字
  • 按编码(UTF-8 / UTF-16)提取
  • 配合 grep 使用

可以告诉我,我可以给你更精确的命令。

0