zoukankan      html  css  js  c++  java
  • linux下对符合条件的文件大小做汇总统计的简单命令

    (1)统计当前目录下的 *txt 文件
    du -c -h *txt
       
    (2)统计当前目录下的 *txt 文件, 并求出总大小
    du  *txt |awk 'BEGIN{count=0;size=0;}
         {count = count + 1; size = size + $1/1024;}
         END{print "Total count " count;
           print "Total size " size/1024 " GB" ;
           print "Avg size " size / count "MB"}'


    (3)统计当前目录下及其子目录中的 +1000000k 文件
    find . -size +1000000k -exec ls -l {} ; |awk 'BEGIN{count=0;size=0;}
         {count = count + 1; size = size + $5/1024/1024;}
         END{print "Total count " count;
           print "Total Size " size/1024 " GB" ;
           print "Avg Size " size / count "MB";
           print "—"}'

    (4)统计当前目录下及其子目录中的 *.fastq
    find . -name '*.fastq' -exec ls -l {} ; |awk 'BEGIN{count=0;size=0;}
         {count = count + 1; size = size + $5/1024/1024;}
         END{print "Total count " count;
           print "Total Size " size/1024 " GB" ;
           print "Avg Size " size / count "MB";
           print "—"}'


    (5)统计当前目录下及其子目录中的之前2天的文件
    find . -mtime -2 -exec ls -l {} ; |awk 'BEGIN{count=0;size=0;}
         {count = count + 1; size = size + $5/1024/1024;}
         END{print "Total count " count;
           print "Total Size " size/1024 " GB" ;
           print "Avg Size " size / count "MB";
           print "—"}'

  • 相关阅读:
    3.java开发环境配置
    2.java主要特性
    1.java中main函数理解
    测试项目团队角色岗位职责
    单身程序员
    软件测评师考试
    vue父子组件通信
    python偏函数使用
    Numpy+Pandas读取数据
    chrome无界面模式headless配置
  • 原文地址:https://www.cnblogs.com/emanlee/p/3527297.html
Copyright © 2011-2022 走看看