《懒人Shell脚本》之十——统计多重路径下的不同扩展名文件及个数

1、统计实现

find -type f | sed -e 's/.*\.//' | sort | uniq -c | sort -n > rst.txt

2、脚本分解

1) find -type f

regular file , 查找正规的文件
返回:./bak_network/道x网站/bak_第8章.md

 b block (buffered) special
 c character (unbuffered) special
 d directory
 p named pipe (FIFO)
 f regular file
 l symbolic link; this is never true if the -L option or the -follow option is in effect, unless the symbolic link is broken. If you want to search for
 symbolic links when -L is in effect, use -xtype.
 s socket
D door (Solaris)

2) sed -e ‘s/.*.//’

任意字符到. 替换为 空,即取得后缀名

3) sort

排序

4) uniq -c

-c, –count
prefix lines by the number of occurrences
第一列统计对应的行数

5) sort -n

compare according to string numerical value
以数字列排序

排序结果为:

  1 docx
  2 jar
  2 part
  4 xlsx
  5 rar
  6 PDF
  17 xls
  122 doc
  149 zip
  322 json
  21305 pdf
  154981 jpg
  1559454 txt
 3029912 html

20170905 思于家中床前
作者:铭毅天下
转载请标明出处,原文地址:
http://blog.csdn.net/laoyang360/article/details/77860110
如果感觉本文对您有帮助,请点击‘喜欢’支持一下,您的支持是我坚持写作最大的动力,谢谢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

铭毅天下

和你一起,死磕Elastic!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值