How can I find all of the distinct file extensions in a folder hierarchy?

后端 未结 16 1281
梦谈多话
梦谈多话 2020-11-30 16:00

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

16条回答
  •  萌比男神i
    2020-11-30 16:43

    Since there's already another solution which uses Perl:

    If you have Python installed you could also do (from the shell):

    python -c "import os;e=set();[[e.add(os.path.splitext(f)[-1]) for f in fn]for _,_,fn in os.walk('/home')];print '\n'.join(e)"
    

提交回复
热议问题