Linux Command strings - 打印文件中可打印的字符

strings

打印文件中的可打印字符串(print the strings of printable characters in files)。常用来在二进制文件中查找字符串,与grep配合使用。strings命令输出的字符串长度为4个或4个以上的,长度小于4的字符串将不予打印,我们可以通过-n参数调整,strings -n 2 filename。

打印文件中可打印的字符。 这个文件可以是文本文件(test.c), 可执行文件(test), 动态链接库(test.o), 静态链接库(test.a)。

参考:https://blog.csdn.net/stpeace/article/details/46641069

举个例子
/// @file tmp.cc
#include <cstdio>

namespace zhaolu
{
	int hello = 1;
	int world = 2;
}

void hello_world()
{
	printf("%d\n",zhaolu::hello);
}

int main()
{
	int hello;
	printf("hello world");
	return 0;
}

使用strings:

:strings tmp.cc
#include <cstdio>
namespace zhaolu
int hello = 1;
int world = 2;
void hello_world()
printf("%d\n",zhaolu::hello);
int main()
int hello;
printf("hello world");
return 0;
:strings tmp.cc | grep hello
int hello = 1;
void hello_world()
printf("%d\n",zhaolu::hello);
int hello;
printf("hello world");

生成目标文件:

:gcc -c -o tmp.o tmp.cc

用strings查看:

:strings tmp.o
hello world
发布了152 篇原创文章 · 获赞 6 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/LU_ZHAO/article/details/104905101