1

The file -b <path> command seems useful for scripting (filtering file types, not necessarily by extension). But for that you have to know the actual string output for your target filetype(s)

If I want to match certain file types, but don't have all of them handy, is there a list of all the possible outputs?

I found docs for the magic file - using cat /usr/share/misc/magic.mgc | grep -a 'pattern' sort of works, but it's awkward and you have to know exactly what you're looking for.

is there any documentation of the recognized file types somewhere?

Thanks!

1

1 Answer 1

3

Read man file and use file -l.
file inspect the first few bytes of a file to determine the "type". Note that Unix/Linux filenames treat "extensions" as just part of the filename. The use of the ".ext" extensions are just tradition, not a requirement.

2
  • "The use of the ".ext" extensions are just tradition, not a requirement." - there were loose conventions around this but it was a hard requirement in the early versions of MS-Windows. But I have no idea why this was downvoted, file -l exactly answers the questions asked
    – symcbean
    Feb 17, 2022 at 1:28
  • file -l seems like exactly what I was looking for! thanks Feb 22, 2022 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.