zoukankan      html  css  js  c++  java
  • Linux Find

    1. Find old files and delete

    -exec: find命令对匹配的文件执行该参数所给出的shell命令。相应命令的形式为'command' { } \;,注意{ }和\;之间的空格。

    -mtime   -n +n                #按文件更改时间来查找文件,-n指n天以内,+n指n天以前

    -ctime    -n +n              #按文件创建时间来查找文件,-n指n天以内,+n指n天以前

    -type    b/d/c/p/l/f         #查是块设备、目录、字符设备、管道、符号链接、普通文件

    "find $HOME -type f -mtime +365 -exec ls -lh {} +" will give you the size and path of every file over 365 days old in your home directory

    2. Find big files and delete

    -size      n[c]               #查长度为n块[或n字节]的文件

    "find $HOME -type f -size +2G -exec ls -lh {} +" will give you the size and path of every file over 2 GB in your home directory

    3. Combine 1 & 2

    "find $HOME -type f -size +2G -mtime +365 -exec ls -lh {} +"

    4. delete specific files under $HOME

    find $HOME -name 'test-file-*' | xargs rm -rf (use rm directly would fail if the file number is more than 20,000)

    -iname will case-insensitive

    Always go with the choice that scares you the most, because that's the one that is going to require the most from you!
  • 相关阅读:
    NOIP模拟测试2「排列 (搜索)·APIO划艇」
    Linux运维基础
    Linux之权限详解
    Linux之特殊符号与正则表达式
    Linux之命令进阶
    Linux分区的几种方案
    开启MySQL远程访问权限 允许远程连接
    Linux命令
    win10 激活(亲测可用)
    帮你解决无法早起的焦虑-顺便撸羊毛
  • 原文地址:https://www.cnblogs.com/sanquanfeng/p/3046010.html
Copyright © 2011-2022 走看看