osh*_*nen 4 linux debian terminal recursive ubuntu
如何递归生成一个文本文件,其中包含我服务器上所有文件的列表,其中包含文件中任何位置的特定字符串?
我知道以下命令可用于递归替换字符串
find /var/www -type f -print0 | xargs -0 sed -i 's/old string/new string/g'
Run Code Online (Sandbox Code Playgroud)
我不想替换字符串,我只想要包含该字符串的所有文件的列表。
使用grep代替sed:
find /var/www -type f -print0 | xargs -0 grep -i 'old string'
Run Code Online (Sandbox Code Playgroud)
从你表达这个问题的方式来看,你似乎还不太熟悉grep. 在其手册页类型中阅读有关其选项的更多信息:man grep在您的命令行中。
更新以回答评论- 尝试添加-l仅显示文件名的选项。将-i使得搜索不区分大小写。两者都易于使用,只需一个破折号:grep -il
| 归档时间: |
|
| 查看次数: |
7158 次 |
| 最近记录: |