---
title: "[centos]文件查找命令笔记"
author: "liu86th"
date: "2015-02-02T15:29:42Z"
tags: []
categories: ["操作系统"]
slug: "centos"
draft: false
lastmod: "2015-02-02T15:29:42Z"
id: 1689090
url: "https://liu86th.iteye.com/blog/1689090"
---

```
 [1] which [command] 查找命令目录 提供别名信息

 [2] whereis [command] 查找命令目录 提供帮助信息
 
 [3] find [filepath|keywords]
 
 [4] find dirname -name [keywords] 根据文件名查找，尽量缩小搜索范围
 
 [5] * 匹配任意字符 find ./ -name test*
 
 [6] ? 匹配单个字符串find ./ -name test???
 
 [7] 查找原则：暂用资源越少越好
 
 [8] find dirname -size +204800 +:大于 -：小于 空：等于 单位为数据块（block=512byte） 100M = 1024k = 102400byre = 102400*2 = 204800block
 
 [9] find dirname -user kewen 查找所有者kewen的文件
 
 [10]天数：ctime/atime/mtime c-change(属性修改过) a-access(访问过) m-modify(内容修改过)
 
 [11]分钟：cmin/amin/mmin -num：num分钟之内 +num：大于多少分钟
 
 [12]find dirname -name init* -a -type f (查找二进制文件) -a(and) -type(类型)
 
 [13]find dirname -name inittab -o -size +204800 -o(or)
 
 [14]find ... -exec command {} \; {}:查找结果 \：转义符
 
 [15]find ./ -name init* -exec rm -rf {} \; 查询之后，执行操作
 
 [16]find ./ -name init* -ok rm -rf {} \; 询问是否执行操作 和 -exec差别
 
 [17]find ./ -inum num -exec rm {} \; 删除特殊字符通用方法
 
 [18]locate file (list files in databases) 和 updatedb定期更新文件数据库
 
 [19]grep [指定字符串][源文件] grep ftp /etc/services
```