A command to list all file formats in a directory?

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
518
Reaction score
447
Credits
2,304
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
865
Reaction score
1,660
Credits
809
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
518
Reaction score
447
Credits
2,304
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
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Staff online


Latest posts

Top