linux系统中统计指定类型文件大小的总和

1、测试数据

[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]# ls *.map | xargs du -ch
41M     a.map
61M     b.map
21M     result.map
121M    total
[root@centos7 test2]# ls *.map | xargs du -ch | tail -n 1
121M    total

ped

[root@centos7 test2]# ls *.ped | xargs du -h
204M    a.ped
407M    b.ped
611M    c.ped
[root@centos7 test2]# ls *.ped | xargs du -ch
204M    a.ped
407M    b.ped
611M    c.ped
1.2G    total
[root@centos7 test2]# ls *.ped | xargs du -ch | tail -n 1
1.2G    total
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14661210.html