Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the find command of linux

Shulou Source: shulou.com Published: 2022-06-01 04:19:00 10月05日 Update

This article mainly shows you "linux find command how to use", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "linux find command how to use" this article.

Find

So what if you don't know where the file is? Let's find them!

If you don't have find on your system, you can install it using DNF:

$sudo dnf install findutils

If no options or parameters are added when running find, it will recursively list all files and directories in the current directory.

$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

But what's really powerful about find is that you can search with file names:

$find-name do-things.sh./Documents/work/project-abc/do-things.sh

Or just part of the name-like a file suffix. Let's look for all the .txt files:

$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

You can also find files according to their size. This method may be especially useful if you don't have enough space. Now list all files greater than 1 MB:

$find-size + 1M./Pictures/trees.png./Pictures/wallpaper.png

Of course, you can also search for a specific directory. Suppose I want to find a file under my Documents folder, and I know that the word "project" is in its name:

$find Documents-name "* project*" Documents/work/project-abcDocuments/work/project-abc/project-notes.txt

In addition to files, it also displays directories. You can limit your search to query files:

$find Documents-name "* project*"-type fDocuments/work/project-abc/project-notes.txt

Finally, find has a lot of options for you to use, and if you want to use them, the man man page can definitely help you:

$man findvia: the above https://fedoramagazine.org/commandline-quick-tips-locate-file/ is all the contents of this article entitled "how to use the find Command of linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: File directory command content article search name if learn help powerful parameter suffix size manual file name folder method time easy to understand Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple OPPO Reno Linux vpn