小编Sam*_*Sam的帖子

在linux命令行中使用find和grep来搜索具有特定用户和文本内容的文件?

我试图找到属于特定用户的文件,该文件还包含特定的文本字符串.例如,我想找到一个属于root用户的文件,并包含"hello there"文本.

我知道我可以使用grep搜索文件中的文本,例如:

grep -irl "hello there" /directory1
Run Code Online (Sandbox Code Playgroud)

而且,我知道我可以搜索具有特定扩展名的用户拥有的文件:

find -user root -name "*.txt"
Run Code Online (Sandbox Code Playgroud)

有没有办法可以将这两个命令结合起来?

linux bash shell

3
推荐指数
1
解决办法
248
查看次数

标签 统计

bash ×1

linux ×1

shell ×1