如何在文件夹层次结构中找到所有不同的文件扩展名? [英] How can I find all of the distinct file extensions in a folder hierarchy?

查看:122
本文介绍了如何在文件夹层次结构中找到所有不同的文件扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一台Linux机器上,我想遍历一个文件夹层次结构,并得到所有不同文件扩展名的列表。



最好的方法是什么从一个shell实现这一点?

解决方案

试试这个(不知道这是最好的方法,但它的工作原理) p>

  find。 -type f | perl -ne'print $ 1 if m / \。([^。\ /] +)$ /'| sort -u 

它的工作如下:


  • 查找当前文件夹中的所有文件

  • 打印文件的扩展名(如果有的话)
  • li>

On a Linux machine I would like to traverse a folder hierarchy and get a list of all of the distinct file extensions within it.

What would be the best way to achieve this from a shell?

解决方案

Try this (not sure if it's the best way, but it works):

find . -type f | perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -u

It work as following:

  • Find all files from current folder
  • Prints extension of files if any
  • Make a unique sorted list

这篇关于如何在文件夹层次结构中找到所有不同的文件扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆