关于find精确查找

find精确查找
 问题

  1. 新建一个目录study,在study目录下建子目录subdir
  2. 在study目录下创建测试文件ipadd.txt,存入eth0网卡的IP地址信息
  3. 为ipadd.txt创建快捷方式ip.txt,放在study/subdir/下
  4. 分别找出study目录下的快捷方式、普通文件、文件夹
  5. 找出/etc/目录下名称以res开头的conf结尾的配置文件
  6. 复制/boot/目录下的内核程序(vmlinuz开头的文件)到study目录下
  7. 找出study目录下大小超过1KB的文件
  8. 找出/sbin目录下大小超过300KB的文件
     方案
    格式:find [路径] [条件]
    默认不指定路径,就是当前路径
    常用选项:
    1) -type 类型
     f 文件
     d 目录
     l 链接
     b 块设备文件
     c 字符设备文件
    2) -name 名字
    3) -size 大小(单位c表示byte,k表示1024bytes)
     + 大于
     - 小于
    4) -mtime 文件内容修改
     n n为数字,意义在n天之前的“一天之内”被更改过的文件
     +n 列出在n天之前(不含n天本身)被更改过的文件名
     -n 列出在n天之内(含n天本身)被更改过的文件名
    5) -a 多个条件同时满足
    6) -o 多个条件满足一条即可
     步骤
    实现此案例需要按照如下步骤进行。
    步骤一:新建一个目录study,在study目录下建子目录subdir
    命令操作如下所示:
    [root@localhost /]# mkdir -p /study/subdir
    [root@localhost ~]# ls -R /study/
    /study/:
    subdir

/study/subdir:
[root@localhost ~]#
步骤二:在study目录下创建测试文件ipadd.txt,存入eth0网卡的IP地址信息
命令操作如下所示:
[root@localhost /]# ifconfig > /study/ipadd.txt
[root@localhost /]# ls /study/
ipadd.txt subdir
[root@localhost /]#
步骤三:为ipadd.txt创建快捷方式ip.txt,放在study/subdir/下
命令操作如下所示:
[root@localhost /]# ln -s /study/ipadd.txt /study/subdir/ip.txt
[root@localhost /]# ls /study/subdir/
ip.txt
[root@localhost /]# ls -l /study/subdir/
总用量 0
lrwxrwxrwx. 1 root root 16 1月 8 21:07 ip.txt -> /study/ipadd.txt
[root@localhost /]#
步骤四:分别找出study目录下的快捷方式、普通文件、文件夹
在study目录下查找快捷方式,命令操作如下所示:
[root@localhost /]# find /study/ -type l
/study/subdir/ip.txt
[root@localhost /]#
在study目录下查找普通文件,命令操作如下所示:
[root@localhost /]# find /study/ -type f
/study/ipadd.txt
[root@localhost /]#
在study目录下查找文件夹,命令操作如下所示:
[root@localhost /]# find /study/ -type d
/study/
/study/subdir
[root@localhost /]#
步骤五:找出/etc/目录下名称以res开头的conf结尾的配置文件
命令操作如下所示:
[root@localhost /]# find /etc/ -name "resconf"
/etc/selinux/restorecond.conf
/etc/selinux/restorecond_user.conf
/etc/resolv.conf
[root@localhost /]#
步骤六:复制/boot/目录下的内核程序(vmlinuz开头的文件)到study目录下
命令操作如下所示:
[root@localhost /]# ls /study/
ipadd.txt subdir
[root@localhost /]# cp /boot/vmlinuz
 /study/
[root@localhost /]# ls /study/
ipadd.txt subdir vmlinuz-2.6.32-431.el6.x86_64
[root@localhost /]#
步骤七:找出study目录下大小超过1KB的文件
命令操作如下所示:
[root@localhost /]# find /study/ -size +1k
/study/
/study/vmlinuz-2.6.32-431.el6.x86_64
/study/subdir
/study/ipadd.txt
[root@localhost /]#
步骤七:找出/sbin目录下大小超过300KB的文件
命令操作如下所示:
[root@localhost /]# find /sbin/ -size +300k
/sbin/insmod.static
/sbin/ldconfig
/sbin/mdadm
/sbin/lvm
/sbin/dhclient
/sbin/busybox
/sbin/grub
/sbin/mdmon
/sbin/rsyslogd
/sbin/sln
[root@localhost /]#

 
posted @ 2020-12-01 15:23  25岁男孩的梦想  阅读(207)  评论(0编辑  收藏  举报