17 find查找高级应用

find查找高级应用

一、根据文件属性查找

(一)忽略文件名大小写

​ 根据名称查找,忽略大小写

​ -iname

[root@localhost ~]# find /etc/ -iname "network*"
/etc/sysconfig/network-scripts
/etc/sysconfig/network-scripts/network-functions-ipv6
/etc/sysconfig/network-scripts/network-functions
/etc/sysconfig/network
/etc/networks
/etc/systemd/system/multi-user.target.wants/NetworkManager.servic
/etc/systemd/system/network-online.target.wants
/etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service
/etc/rc.d/init.d/network
/etc/selinux/targeted/active/modules/100/networkmanager
/etc/libvirt/qemu/networks
/etc/vmware-tools/scripts/vmware/network
/etc/NetworkManager
/etc/NetworkManager/NetworkManager.conf

(二)指定文档归属

​ 根据账号名称或ID查找

​ -uid(标识用户)、-gid(标识组)、-user、-group

​ -nouser、-nogroup

[root@localhost ~]# find /dev/ -group cdrom
/dev/sg1
/dev/sr0

[root@localhost ~]# ls -lh /dev/{sg1,sr0}
crw-rw----+ 1 root cdrom 21, 1 71 21:54 /dev/sg1
brw-rw----+ 1 root cdrom 11, 0 71 21:54 /dev/sr0

[root@localhost ~]# id deer-fish
uid=1000(deer-fish) gid=1000(deer-fish)=1000(deer-fish),10(wheel)

[root@localhost ~]# find /home/ -uid 1000
/home/deer-fish
/home/deer-fish/文档
/home/deer-fish/.bash_history
/home/deer-fish/.cache
/home/deer-fish/.cache/gnome-software
/home/deer-fish/.cache/gnome-software/odrs
/home/deer-fish/.cache/gnome-software/shell-extensions
/home/deer-fish/.cache/gstreamer-1.0
/home/deer-fish/.cache/gstreamer-1.0/registry.x86_64.bin
/home/deer-fish/.cache/abrt
……

(三)指定文档i节点编号

​ 同一个文件系统内文件的i节点编号具有唯一性

​ 当文件名存在乱码等现象时,方便定位文档

​ -inum

[root@localhost ~]# touch /data/text01.txt

[root@localhost ~]# ls /data
text01.txt

[root@localhost ~]# ls -i /data/text01.txt
11 /data/text01.txt

[root@localhost ~]# find /data/ -inum 11
/data/text01.txt

二、限制查找深度

(一)最多查到第几层目录

​ 从指定目录(第1层)查找,最多深入到第x层目录

​ -maxdepthx层

[root@localhost ~]# find /etc -maxdepth 2 -name "res*"
/etc/resolv.conf.save
/etc/vmware-tools/resume-vm-default
/etc/resolv.conf

(二)最少从第几层目录查找

​ 从指定目录(第1层)查找,最多深入到第x层目录

​ -maxdepthx层

[root@localhost ~]# find /etc -mindepth 2 -name "res*"
/etc/vmware-tools/resume-vm-default
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值