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

​​​​​​​


相关推荐
VidDown35 分钟前
用户说“卡顿“,服务器一切正常:播放质量监测与 QoE 指标
运维·服务器·ffmpeg·音视频·视频
暖核39 分钟前
从零搭建 Ubuntu24.04 服务器:虚拟机安装 + Netplan 静态 IP+SSH 远程登录
服务器·tcp/ip·ssh
瑞克-桑切斯40 分钟前
13、DNS、DHCP 与 FTP 协议详解
linux·运维·云计算
程序员-Benothing43 分钟前
Linux性能分析方法论:USE、RED、火焰图与perf实战
linux·运维·服务器
问心无愧05131 小时前
[ACTF2020 新生赛]Exec
运维·服务器·笔记
cg.family1 小时前
K8S:scale 与 delete pod 核心区别
运维·docker·容器
微订校园外卖平台1 小时前
同城外卖跑腿平台需要服务器吗?交付方式、部署架构与上线核对
服务器·架构·github·外卖系统·本地生活·微订
发量惊人的中年网工1 小时前
游戏出海服务器选哪个IDC?开服卡顿、延迟抖动的排查与选节点思路
服务器·idc
开开心心_Every1 小时前
黄金价格软件国内外价格实时监控超方便
运维·服务器·游戏·智能手机·pdf·lua·perl
云中双月1 小时前
瑞芯微rv1106进入Loader模式转储emmc数据
linux·嵌入式·uboot·u-boot·emmc·rockchip·烧录·rv1106·瑞芯微