Linux Find 命令详情解释

文件查找

  • 普通查询
  • find /etc -maxdepth 1 -type f -name "pa*"
  • 命令 目录... 查找深度 类型 文件名称包含
    • -type文件类型:f表示文件,不指定类型的话,文件和目录都会查找

    • -maxdepth查找深度:目录层级的意思,不指定的话,就按照最大深度来查找

    • "pa*": *表示匹配任意pa开头的内容,*号还可以写在开头


按照文件大小查找

  • 按照文件大小查找(单位kMG,k要小写,MG要大写,不带单位就按照B单位来查找)
    • 1.查找大于100M的文件
      • find / - type f -size +100M [root@localhost tmp]# find / -type f -size +100M
    • 2.查找小于2k的文件
      • find /root/nginx- 1.20.2 - type f -size -2k
    • 3.查找大于50M同时小于100M的文件
      • find / - type f -size +50M - and -size -100M

忽略大小写查询

  • find /etc -maxdepth 1 -iname "pa*"
    • # i是ignore的简写,忽略的意思

根据修改时间查找文件

  • [root@localhost ~]# stat 1.txt
  • 时间参数:atime mtime ctime amin mmin cmin #(time是按照天来查找,min是按分钟查找)
    • # 时间单位为天
    • find /opt -type f -mtime -1 #-1代表一天以内,+1一天以前
  • 时间单位为分钟

  • 查找1天之前,10天之内,修改过的文件

    • [root@localhost ~]# find /etc/ -type f -mtime +1 -and -mtime -10

取反 !

  • [root@localhost ~] # find /root -type f -name "*.txt" #
    • 找名称以.txt结尾的文件
    • /root/ 1. txt /root/学习前准备.txt
  • [root@localhost ~] # find /root -type f ! -name "*.txt"
    • # 找名称中不是.txt结尾的 文件 /root/.bash_logout

用户组查找

  • 根据用户来查找文件

    • [root@localhost ~] # useradd hao
    • [root@localhost ~] # find / -user hao
  • # 查找属于hao用户的所有目录和文件

  • 根据用户组来查

    • ​​​​​​​find / -group hao

​​​​​​​


相关推荐
墨风如雪4 小时前
甲骨文云(Oracle Cloud)最新注册防坑记录:被ABC了怎么办?
服务器
xingfujie5 小时前
运维实战攻略
运维
HHFQ5 小时前
在 systemd 场景下的 CPU 限制方式
linux
道清茗5 小时前
【RH294知识点汇总】第 9 章 《 自动执行 Linux 管理任务 》常见问题
linux·运维·服务器
山羊硬件Time5 小时前
自动化管理Linux的好工具:shell script
linux·嵌入式硬件·硬件工程师·基带工程·硬件开发
北方的流星5 小时前
华三路由器NAT配置
运维·网络·华三
wj3055853786 小时前
Codex + Git 开发环境配置指南(WSL版)
linux·运维·git
星马梦缘6 小时前
如何切换window-ubuntu双系统【方案二】
linux·运维·ubuntu
2501_927283587 小时前
荣联汇智助力天津艺虹打造“软硬一体”智慧工厂,全流程自动化引领印刷包装行业数智变革
大数据·运维·数据仓库·人工智能·低代码·自动化
HXDGCL7 小时前
矩形环形导轨:自动化循环线的核心运动单元解析
运维·算法·自动化