我怎样才能找到一个文件/目录,可以在任何地方在Linux命令行? [英] How can I find a file/directory that could be anywhere on linux command line?

查看:201
本文介绍了我怎样才能找到一个文件/目录,可以在任何地方在Linux命令行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

理想情况下,我可以使用程序,如
$ b $ pre $ find $文件或目录名

报告具有匹配文件名/目录的路径。不幸的是,这似乎只检查当前目录,而不是整个文件夹。

我也试过找到和哪个,但没有找到该文件,即使我知道它在电脑的某个地方。

解决方案

不幸的是,这似乎只检查当前目录,而不是整个文件夹。大概你的意思是它不看在子目录。要解决这个问题,使用 find -namefilename



如果有问题的文件不在当前工作目录下,你可以通过

  find / -namefilename

这也适用于 find / -name* .pdf等等。有时候我也喜欢把它变成一个grep语句(因为至少在我的机器上,它会突出显示结果),所以我最终得到了类似于

  find / -name* star * wars *| grep star 

执行此操作或类似的方法只是帮助我立即找到文件名并识别它是否在实际上我正在寻找的文件。


Ideally, I would be able to use a program like

find [file or directory name]

to report the paths with matching filenames/directories. Unfortunately this seems to only check the current directory, not the entire folder.

I've also tried locate and which, but none find the file, even though I know its on the computer somewhere.

解决方案

"Unfortunately this seems to only check the current directory, not the entire folder". Presumably you mean it doesn't look in subdirectories. To fix this, use find -name "filename"

If the file in question is not in the current working directory, you can search your entire machine via

find / -name "filename"

This also works with stuff like find / -name "*.pdf", etc. Sometimes I like to pipe that into a grep statement as well (since, on my machine at least, it highlights the results), so I end up with something like

find / -name "*star*wars*" | grep star

Doing this or a similar method just helps me instantly find the filename and recognize if it is in fact the file I am looking for.

这篇关于我怎样才能找到一个文件/目录,可以在任何地方在Linux命令行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆