zoukankan      html  css  js  c++  java
  • linux命令-find

    1. 主要作用

    在目录中查找文件

    2. 按文件名查找

    命令:

    find . -name "*.sw[p o]"
    

    说明:在当前目录及子目录中查找.swp或.swo文件,可以通过[]来进行文件名扩展

    3. 按目录深度查找

    命令:

    find . -name "user*" -maxdepth 2
    find . -name "user*" -mindepth 2
    

    说明:
    -maxdepth 2 目录深度大于2时不再查找
    -mindepth 2 目录深度小于2时不再查找

    4. 按文件类型查找

    命令:

    find . -name "user*" -type d
    find . -name "user*" -type f
    find . -name "user*" -type l
    

    说明:
    -type d, 目标文件为directory
    -type f, 目标文件为regular file
    -type l, 目标文件为symbolic link

    5. 按用户名查找

    命令:

    find . -user root
    

    说明:-user root,目标文件所属用户名为root

    6. 按文件大小查找

    命令:

    find . -size +512k # 查找大于512k的文件
    find . -size +1M   # 查找大于1M的文件
    find . -size -512k -type f # 查找小于512k的普通文件
    

    说明:见命令

    7. 查找空目录或size=0的文件

    命令:

    find . -empty
    

    说明:略

    8. 按时间查找

    命令:

    find . -atime -2 # 查找2天内访问过的文件
    find . -atime +2 # 查找2天前访问过的文件
    
    find . -mtime -2 # 查找2天内修改过的文件
    find . -mtime +2 # 查找2天前修改过的文件
    
    find . -ctime -2 # 查找2天内状态改动过的文件
    find . -ctime +2 # 查找2天前状态改动过的文件
    #---------------
    find . -amin -60 # 查找60分钟内访问过的文件
    find . -amin +60 # 查找60分钟前访问过的文件
    
    find . -mmin -60 # 查找60分钟内修改过的文件
    find . -mmin +60 # 查找60分钟前修改过的文件
    
    find . -cmin -60 # 查找60分钟内状态改动过的文件
    find . -cmin +60 # 查找60分钟前状态改动过的文件
    

    说明:

    1. atime, 是指access time,使用more、cat等命令获取文件内容,会更新这个时间,ls、stat等不会。
    2. mtime,是指modify time,使用vim修改并保存,会更新这个时间,ls -l列出的时间即mtime。
    3. ctime,是指change time,该文件的i节点最后一次被修改的时间,chmod、chown命令修改文件属性时,这个时间会更新。

    9. help信息

    $ find -help
    Usage: find [-H] [-L] [-P] [-Olevel] [-D debugopts] [path...] [expression]
    
    default path is the current directory; default expression is -print
    expression may consist of: operators, options, tests, and actions:
    operators (decreasing precedence; -and is implicit where no others are given):
          ( EXPR )   ! EXPR   -not EXPR   EXPR1 -a EXPR2   EXPR1 -and EXPR2
          EXPR1 -o EXPR2   EXPR1 -or EXPR2   EXPR1 , EXPR2
    positional options (always true): -daystart -follow -regextype
    
    normal options (always true, specified before other expressions):
          -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
          --version -xdev -ignore_readdir_race -noignore_readdir_race
    tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
          -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
          -ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
          -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
          -nouser -nogroup -path PATTERN -perm [-/]MODE -regex PATTERN
          -readable -writable -executable
          -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
          -used N -user NAME -xtype [bcdpfls]      -context CONTEXT
    
    actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print
          -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit
          -exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;
          -execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;
    
    Valid arguments for -D:
    exec, opt, rates, search, stat, time, tree, all, help
    Use '-D help' for a description of the options, or see find(1)
    
    Please see also the documentation at http://www.gnu.org/software/findutils/.
    You can report (and track progress on fixing) bugs in the "find"
    program via the GNU findutils bug-reporting page at
    https://savannah.gnu.org/bugs/?group=findutils or, if
    you have no web access, by sending email to <bug-findutils@gnu.org>.
    
  • 相关阅读:
    海量数据面试题整理
    JConsole操作手册
    JVM调优总结(十二)-参考资料
    JVM调优总结(十一)-反思
    JVM调优总结(十)-调优方法
    JVM调优总结(八)-典型配置举例2
    JVM调优总结(九)-新一代的垃圾回收算法
    JVM调优总结(七)-典型配置举例1
    JVM调优总结(五)-分代垃圾回收详述1
    JVM调优总结(六)-分代垃圾回收详述2
  • 原文地址:https://www.cnblogs.com/gaiqingfeng/p/13572519.html
Copyright © 2011-2022 走看看