Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the find command of linux

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report