Getting a file's MIME type
Has a file ever seemed to be in a certain format, but the application you use can’t handle it?
This can happen, for example, when the file extension is wrong. How can we find out what type of file we have?
To get the MIME type of a file, and so work out which application can handle it, we can use the file command.
We can use the command like this:
file --mime-type filename.extThis gives us the file’s MIME type. If we only want the file’s encoding, we can use –mime-encoding instead of –mime-type.
file --mime-encoding filename.extWe can also get both pieces of information with the -i option:
file -i filename.ext