type
status
date
slug
summary
tags
category
icon
password
1. find 命令
find 是最常用的查找命令,可以在指定目录及其子目录下查找符合条件的文件。基本用法如下:- 查找指定目录下所有
.txt文件:
- 查找当前目录下所有名为
file1.txt的文件:
- 查找并删除
.log文件:
2. locate 命令
locate 基于事先生成的文件数据库来查找文件,因此查找速度较快,但需要定期更新数据库。使用时不需要遍历文件系统,可以非常快速地返回结果。- 查找文件:
- 例如查找所有
.txt文件:
- 更新数据库(需要 root 权限):
3. which 命令
which 用来查找某个命令或可执行文件在系统中的路径。- 查找
python命令的位置:
4. whereis 命令
whereis 用于查找程序、源代码和 man 手册页的位置。与 which 类似,但 whereis 搜索的范围更广。- 查找
gcc的可执行文件、源代码及 man 页面:
5. find 配合 grep 命令
find 和 grep 可以结合使用,查找包含特定文本的文件。- 查找包含文本 "example" 的所有
.txt文件:
- Author:Gweek
- URL:https://tangly1024.com/article/linuxczwjml
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
Relate Posts













