zoukankan      html  css  js  c++  java
  • linux系统中统计指定文件类型的文件大小

    1、测试数据

    [root@centos7 test2]# ls
    a.map  a.ped  b.map  b.ped  c.ped  result.map
    [root@centos7 test2]# ll -h
    total 1.4G
    -rw-r--r--. 1 root root  41M Apr 15 09:47 a.map
    -rw-r--r--. 1 root root 204M Apr 15 09:47 a.ped
    -rw-r--r--. 1 root root  61M Apr 15 09:48 b.map
    -rw-r--r--. 1 root root 407M Apr 15 09:47 b.ped
    -rw-r--r--. 1 root root 611M Apr 15 09:47 c.ped
    -rw-r--r--. 1 root root  21M Apr 15 09:44 result.map

    2、统计map文件的大小

    [root@centos7 test2]# ll -h *.map
    -rw-r--r--. 1 root root 41M Apr 15 09:47 a.map
    -rw-r--r--. 1 root root 61M Apr 15 09:48 b.map
    -rw-r--r--. 1 root root 21M Apr 15 09:44 result.map

    简化

    [root@centos7 test2]# ls *.map | xargs du -h
    41M     a.map
    61M     b.map
    21M     result.map

    排序,从大致小

    [root@centos7 test2]# ls -S *.map | xargs du -h
    61M     b.map
    41M     a.map
    21M     result.map

    排序,从小至大

    [root@centos7 test2]# ls -S *.map | tac | xargs du -h
    21M     result.map
    41M     a.map
    61M     b.map

    计算某一类文件总的大小

    [root@centos7 test]# ll -h
    total 413M
    -rw-r--r--. 1 root root  76M Apr 16 08:34 b.map
    -rw-r--r--. 1 root root 151M Apr 16 08:34 c.ped
    -rw-r--r--. 1 root root  30M Apr 16 08:34 d.map
    -rw-r--r--. 1 root root 6.6M Apr 16 08:35 e.ped
    -rw-r--r--. 1 root root 100M Apr 16 08:35 x.map
    -rw-r--r--. 1 root root  51M Apr 16 08:35 y.ped
    [root@centos7 test]# ls *.map | xargs du -ch
    76M     b.map
    30M     d.map
    100M    x.map
    205M    total
    [root@centos7 test]# ls *.map | xargs du -ch | tail -n 1
    205M    total
  • 相关阅读:
    2016年第七届蓝桥杯C/C++ A组国赛 —— 第一题:随意组合
    寻找段落
    攻击火星
    图论入门
    实数加法
    求 10000 以内 n 的阶乘
    大整数因子
    计算2的N次方
    大整数减法
    大整数加法
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14661179.html
Copyright © 2011-2022 走看看