21.linux文件的查找
2016-01-16 23:19
573 查看
locate 非实时查找全系统的文件,依靠一个数据库,非精确的查找
格式:find 查找的路径 查找的标准 查找后的处理
查找的路径 默认为当前的目录
查找的标准 默认为当前路径下的所有文件
查找后的处理 默认为打印
-name FILENAME 对文件名做精确的匹配
* 任意字符任意长度
? 单个任意字符
[] 集合中的一个
-iname 不区分大小写匹配
-regex pattern 基于正则表达式进行文件名匹配
-user USERNAME 基于用户名进行查找
-group GROUP 基于用户组进行查找
-uid
-gid
-nouser 没有用户的文件
-nogroup 没有用户组的文件
-type 格局文件类型查找
-size 根据文件的大小
nk
nM
nG
组合条件
-o 或
-a 与
-not 非
-mtime 天
-ctime
-atime
[+-]n
-MODE 每一位权限都被包含
/MODE 有任何一位符合即可
-print 默认显示
-ls 类似 ls -l
<span style="font-family:Courier New;font-size:14px;">[root@localhost bin]# locate passwd /etc/passwd /etc/passwd- /etc/passwd.OLD /etc/pam.d/passwd /etc/security/opasswd /lib/security/pam_passwdqc.so /lib/security/pam_unix_passwd.so /usr/bin/RSA_SecurID_getpasswd</span>有时候刚刚创建过文件,由于数据库还没有更新,需要我们手动更新
<span style="font-family:Courier New;font-size:14px;">[root@localhost bin]# updatedb</span>find实时查找,精确速度慢,遍历指定的目录
格式:find 查找的路径 查找的标准 查找后的处理
查找的路径 默认为当前的目录
查找的标准 默认为当前路径下的所有文件
查找后的处理 默认为打印
-name FILENAME 对文件名做精确的匹配
<span style="font-family:Courier New;font-size:14px;">[root@localhost bin]# find /etc/ -name "passwd" /etc/pam.d/passwd /etc/passwd</span>文件通配符
* 任意字符任意长度
? 单个任意字符
[] 集合中的一个
-iname 不区分大小写匹配
-regex pattern 基于正则表达式进行文件名匹配
-user USERNAME 基于用户名进行查找
<span style="font-family:Courier New;font-size:14px;">[root@localhost xin]# find ./ -user "xin" ./ ./.bashrc ./.bash_profile ./.bash_logout ./.mozilla ./.mozilla/extensions ./.mozilla/plugins</span></span><pre name="code" class="plain">
-group GROUP 基于用户组进行查找
-uid
-gid
-nouser 没有用户的文件
-nogroup 没有用户组的文件
-type 格局文件类型查找
-size 根据文件的大小
nk
nM
nG
组合条件
-o 或
-a 与
-not 非
[root@localhost ~]# find /tmp -nouser -a -type d [root@localhost ~]# find /tmp -not -type d /tmp/.font-unix/fs7100 /tmp/orbit-root/linc-24d7-0-12486249b9468 /tmp/orbit-root/linc-24d7-0-1950f57c22c71
-mtime 天
-ctime
-atime
[+-]n
[root@localhost ~]# find /tmp -atime +7 /tmp/vmware-config0/99-vmware-scsi-udev.rules /tmp/mapping-root /tmp/keyring-xD2dOV/socket /tmp/ks-script-JxlfUE.log-perm MODE 根据权限来查找
-MODE 每一位权限都被包含
/MODE 有任何一位符合即可
[root@localhost tmp]# find -perm 644 [root@localhost tmp]# find -perm -644 [root@localhost tmp]# find -perm /644处理动作
-print 默认显示
-ls 类似 ls -l
[root@localhost tmp]# find -perm /644 -ls 5832705 8 drwxrwxrwt 13 root root 4096 Jan 17 04:27 .
相关文章推荐
- 段错误之#0 0x00000001 in ?? ()
- 2016-01-16linux下的ssh相关
- Linux学习笔记:使用外部SMTP发送邮件
- Linux学习笔记:创建用户与授权
- linux c函数获取系统IP地址
- 大牛分享的 Linux 性能工具
- Linux学习笔记:MySQL字符集
- [Linux C]百度音乐API实现在线搜歌
- linux下的中断(interrupt)IRQ以及IRQ绑核小结
- linux公钥
- linux下JDK设置
- RT3070 AP模式移植 基于linux3.0内核
- linux面试题大全
- Java开发必会的Linux命令
- Linux下软连接和硬链接的关系
- linux学习笔记----权限与命令之间的关系(极重要)
- Linux crontab 计划执行详解
- Java开发必会的Linux命令
- Linux mysql 主从复制
- linux学习笔记----文件与目录管理