Unix bash 命令
如何编写一个 bash 命令来查找当前目录中包含单词“foo”的所有文件(无论大小写)?
How to write a bash command that finds all files in the current directory that contain the word “foo”, regardless of case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果您希望根据
.
中的文件竞争检查“foo”,请执行以下操作:有关更多选项(-I、-T、...),请参阅
man grep< /代码>。
If you want "foo" to be the checked against the contests of the files in
.
, do this:for more options (-I, -T, ...) see
man grep
.假设您想在文件内部搜索(而不是文件名)
如果您只想搜索当前目录(而不是树)
如果您想扫描整个树(从当前目录)
Assuming you want to search inside the files (not the filenames)
If you only want the current directory to be searched (not the tree)
if you want to scan the entire tree (from the current directory)
Try:
将打印当前目录中与
*foo*
匹配的文件/目录名称,该名称恰好与包含“foo”的任何名称匹配。Try:
will print file/dir names matching
*foo*
in the current directory, which happens to match any name containing 'foo'.我一直使用这个小 shell 命令:
您可以通过
gfind '*php' 'search string'
来调用它,或者如果您想搜索所有文件gfind 'search string'
>I've always used this little shell command:
you call it by either
gfind '*php' 'search string'
or if you want to search all filesgfind 'search string'
寻找 。 -类型 f | grep -i“foo”
find . -type f | grep -i "foo"