freeCodeCamp/guide/chinese/linux/using-the-find-command/index.md

33 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Using the Find Command
localeTitle: 使用查找命令
---
# 使用查找命令
Linux find命令是一个功能强大的工具可帮助您找到服务器上的文件和目录。通过一些练习您可以根据名称类型大小或日期创建或上次更新时轻松跟踪事物。
将find视为您渴望的帮手
你:“我在服务器上找东西。”
发现:“我可以帮忙!你能告诉我什么吗?”
“这是一个大于2GB的文件位于我的主目录下在过去48小时内更新。”
发现:“多田!”
查找是一个程序,所以你必须告诉它`find ~ -type f -size +2G` 。
以下是使用find的一些示例命令
* `find ~ -type d # Show me all the subdirectories inside my home directory`
* `find / -type f -name 'todo.txt' # Show me files named 'todo.txt' anywhere under the root directory (ie anywhere)`
第一个参数总是命名我们将要查看的目录。在上面的示例中,这些是〜(当前用户的主目录)和/(文件系统的根目录)。
其他参数是可选的,可以以您认为有用的任何方式组合:
* type参数允许您仅限制搜索文件f仅限目录d或符号链接l。如果省略type参数则将搜索所有这些类型。
* name参数允许您通过名称指定要查找的内容使用文字字符串'filename.txt')或使用通配符('file。\*')。
`man find`会显示更多参数,值得回顾。查找可以按名称,用户,创建日期,大小等查找文件。下次你在找东西时,找到它!