2011-04-25 28 views
165

我的系統中有一個文件名爲「process.txt」。我正在使用Ubuntu操作系統。我只知道文件名,我不知道哪個目錄和全部?如何找到它在目錄中的文件?我想通過命令知道嗎?我嘗試使用find命令,但它不起作用。如何在Ubuntu中查找文件?

+5

您可能希望下一次來這裏問:http://askubuntu.com/ – 2011-04-25 07:19:45

+0

的'find'命令是正確的。我建議在ServerFault上詢問這個問題,並用'find'顯示你已經嘗試了什麼。 – 2011-04-25 07:21:14

+0

如果你不需要使用命令,你可以使用Dash – hexicle 2013-08-14 07:23:14

回答

172

你試過了:find . -name "process.txt"這將在當前目錄中搜索名爲process.txt的文件。另請參見https://en.wikipedia.org/wiki/Find_(Unix)

+1

@shree,如果你喜歡這個答案最好的,請幫助社區並接受它作爲正確的答案。 – dward 2013-02-01 07:54:19

+12

爲了防止從'/'發現所有被拒絕的權限列表,您可以在命令中追加以下內容:'find/-name'process.txt「2>/dev/null' – br3nt 2016-11-03 00:38:07

26

運行updatedb爲根,然後locate process.txt

+2

這也適用於通配符'locate * .vmoptions *' – 2017-09-20 10:26:50

79

您可以使用:

  • 的索引方式:locate -i process.txt(運行sudo updatedb更新指標,但Ubuntu的通過cronupdate it everyday)。
  • 或者使用find . -iname 'process.txt' -print搜索,如果它位於當前文件夾中。
  • 您可以將其更改爲find/-iname 'process.txt' -print以便從根目錄搜索。

要從find命令是大小寫敏感的刪除-ilocate,或-name代替-iname

圖形,you can use的kfindGNOME搜索工具鮎魚(這是命令,也從官方的回購協議包的名稱)。

+0

最完整的答案... – 2018-03-05 10:25:44

42

試試這個:

find/-name process.txt