• We did not send an email asking for donations - please read this post.

A command to list all file formats in a directory?

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
647
Reaction score
518
Credits
3,613
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
926
Reaction score
1,779
Credits
1,207
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
647
Reaction score
518
Credits
3,613
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

No members online now.

Top