简体   繁体   English

如何找出目录中文件类型的数量

[英]How to find out the number of files types in a directory

So i am trying to write a script to search through a directory and find the number files with the same type. 因此,我试图编写一个脚本来搜索目录并查找具有相同类型的数字文件。 I tried this: 我尝试了这个:

find $directory -type f | file -b $SAVEFILES | cut -c1-40 | sort -n | uniq -c | sort -nr |

but the number of how many times the the same type is there is before the type and look like this: 但是在该类型之前,相同类型存在多少次,看起来像这样:

    168 ASCII TEXT

How do I access value of the number and store it and afterwards move it after the text like this: 我如何访问数字的值并存储它,然后将其移动到像这样的文本之后:

ASCII TEXT: 168

Append with GNU sed: 附加GNU sed:

| sed 's/^ *\([0-9]\+\) \(.*\)/\2: \1/'

or 要么

| sed -r 's/^ *([0-9]+) (.*)/\2: \1/'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM