《懒人Shell脚本》之十——统计多重路径下的不同扩展名文件及个数
2017-12-21 16:10
204 查看
1、统计实现
find -type f | sed -e 's/.*\.//' | sort | uniq -c | sort -n > rst.txt1
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)1
2
3
4
5
6
7
8
9
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 html1
2
3
4
5
6
7
8
9
10
11
12
13
14
20170905 思于家中床前
作者:铭毅天下
转载请标明出处,原文地址:
http://blog.csdn.net/laoyang360/article/details/77860110
如果感觉本文对您有帮助,请点击‘喜欢’支持一下,您的支持是我坚持写作最大的动力,谢谢!
相关文章推荐
- 《懒人Shell脚本》之十——统计多重路径下的不同扩展名文件及个数
- linux shell 统计不同文件扩展名的个数
- [置顶] 从键盘输入一个路径,统计该文件夹下制定扩展名文件的数量(其中文件夹下还包含子文件夹)
- java/android 统计文件夹大小及删除文件夹下所有文件和路径
- 统计输入的字符串各个不同字符出现的频度,并存入文件,合法字符为:“A~Z”和“0~9”
- Java I/O之FilenameFilter类列举出指定路径下某个扩展名的文件
- impdp将不同路径下的dump文件同时…
- log4j自定义不同日志文件及动态配置路径
- 根据EDI文件类型修改EDI文件名称并移至不同路径下
- DB2还原过程中因文件路径不同引发错误
- 不同文件(扩展名)的打开方式
- 文件存储的不同路径记录
- python获取文件路径下的完整文件名(包括扩展名)
- java统计某文件或目录下指定路径的文件数量及行数
- C/C++ 解析文件路径 获取文件名和扩展名
- 获取文件path路径中的文件名(是否包含扩展名)
- java文件路径的不同写法
- Unity3d 在不同设备中的文件读写 的路径
- applicationContext.xml文件放置位置不同而导致的jUnit测试的时候路径的不同
- find 查找不同扩展名的文件