A command to list all file formats in a directory?

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
687
Reaction score
561
Credits
4,106
Hi. Is there a command that will list all file formats found in a directory with a recursive method (meaning that it will list all file formats in subdirs as well)?
 


Rob

Administrator
Staff member
Joined
Oct 27, 2011
Messages
1,183
Reaction score
2,179
Credits
3,316
You could use the file command to show filetype - is that what you're looking for?
Code:
$ file movies.txt
movies.txt: ASCII text

Then, push it through the files in your directory with something like the find command..
find . -type f | file -f -
 
Last edited:
OP
rado84

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
687
Reaction score
561
Credits
4,106
No. But after an hour of searching, I think I found the command. It doesn't have the "-r" flag but it still displays the file extensions from all the subdirs and I'm gonna make an alias of it.

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

Members online


Top