find 查找文件
查找/etc目录下文件名以“yum”开头的文件
[root@localhost test]# find /etc/ -name yum*
/etc/yum.repos.d
/etc/logrotate.d/yum
/etc/yum
/etc/yum/yum-cron-hourly.conf
/etc/yum/yum-cron.conf
/etc/yum.conf
参数
-name 匹配名称
-perm 匹配权限( mode 为完全匹配, -mode 为包含即可)
-user 匹配所有者
-group 匹配所有组
-mtime -n +n 匹配修改内容的时间( -n 指 n 天以内, +n 指 n 天以前)
-atime -n +n 匹配访问文件的时间( -n 指 n 天以内, +n 指 n 天以前)
-ctime -n +n 匹配修改文件权限的时间( -n 指 n 天以内, +n 指 n 天以前)
-nouser 匹配无所有者的文件
-nogroup 匹配无所有组的文件
-newer f1 !f2 匹配比文件 f1 新但比 f2 旧的文件
–type b/d/c/p/l/f 匹配文件类型(后面的字幕参数依次表示块设备、目录、字符设备、管道、链接文件、文本文件)
-size 匹配文件的大小( +50KB 为查找超过 50KB 的文件,而 -50KB 为查找小于 50KB 的文件)
-prune 忽略某个目录
-exec …… {}; 后面可跟用于进一步处理搜索结果的命令
grep 在文本中搜索关键词
搜索yum.conf文件中包含“yum”的行,并显示行号
[root@localhost test]# grep -n yum /etc/yum.conf
2:cachedir=/var/cache/yum/$basearch/$releasever
5:logfile=/var/log/yum.log
11:bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
15:# This is the default, if you make this bigger yum won't see if the metadata
17:# download the new metadata and "pay" for it by yum not having correct
22:# manually check the metadata once an hour (yum-updatesd will do this).
26:# in /etc/yum.repos.d
参数
-n 显示行号
-v 反向选择(仅显示没有关键词的行)
-c 仅显示有关键词的行数
-i 忽略大小写