在 Ubuntu 的整个服务器上使用 Grep

see*_*edg 3 linux grep

我需要在整个服务器上使用 grep 工具。

我尝试了以下方法:

grep -r 'MyString' / 
grep -r 'MyString' /*
Run Code Online (Sandbox Code Playgroud)

然而,这些似乎都不起作用。有什么建议?

小智 5

sudo find / -type f -exec grep "Strring" {} \;
Run Code Online (Sandbox Code Playgroud)

你确定要这样做吗?这将遍历所有文件系统(本地或非本地),并且很可能使服务器上的 CPU 达到最大值。