這篇文章主要為大家展示了“linux的find命令怎么用”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“linux的find命令怎么用”這篇文章吧。
find
那么如果不知道文件在哪里呢?就讓我們來找到它們吧!
要是你的系統中沒有 find,你可以使用 DNF 安裝它:
$ sudo dnf install findutils
運行 find 時如果沒有添加任何選項或者參數,它將會遞歸列出當前目錄下的所有文件和目錄。
$ find . ./Documents ./Documents/secret ./Documents/secret/christmas-presents.txt ./Documents/notes.txt ./Documents/work ./Documents/work/status-reports.txt ./Documents/work/project-abc ./Documents/work/project-abc/README.md ./Documents/work/project-abc/do-things.sh ./Documents/work/project-abc/project-notes.txt ./.bash_logout ./.bashrc ./Videos ./.bash_profile ./.vimrc ./Pictures ./Pictures/trees.png ./Pictures/wallpaper.png ./notes.txt ./Music
但是 find 真正強大的是你可以使用文件名進行搜索:
$ find -name do-things.sh ./Documents/work/project-abc/do-things.sh
或者僅僅是名字的一部分 —— 像是文件后綴。我們來找一下所有的 .txt 文件:
$ find -name "*.txt" ./Documents/secret/christmas-presents.txt ./Documents/notes.txt ./Documents/work/status-reports.txt ./Documents/work/project-abc/project-notes.txt ./notes.txt
你也可以根據大小尋找文件。如果你的空間不足的時候,這種方法也許特別有用?,F在來列出所有大于 1 MB 的文件:
$ find -size +1M ./Pictures/trees.png ./Pictures/wallpaper.png
當然也可以搜索一個具體的目錄。假如我想在我的 Documents 文件夾下找一個文件,而且我知道它的名字里有 “project” 這個詞:
$ find Documents -name "*project*" Documents/work/project-abc Documents/work/project-abc/project-notes.txt
除了文件它還顯示目錄。你可以限制僅搜索查詢文件:
$ find Documents -name "*project*" -type f Documents/work/project-abc/project-notes.txt
最后再一次,find 還有很多供你使用的選項,要是你想使用它們,man 手冊頁絕對可以幫到你:
$ man find via: https://fedoramagazine.org/commandline-quick-tips-locate-file/
以上是“linux的find命令怎么用”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。