A command to list all file formats in a directory?

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
603
Reaction score
483
Credits
3,137
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
915
Reaction score
1,736
Credits
1,129
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
603
Reaction score
483
Credits
3,137
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!

Linux.org Hosting Donations
Consider making a donation

Members online


Latest posts

Top