A multipurpose internet mail extension, or MIME type, is an internet standard that describes the contents of internet files based on their natures and formats. This cataloging helps the browser open the file with the appropriate extension or plugin.
A MIME type has two parts: a type and a subtype. They are separated by a slash (/). For example, the MIME type for Microsoft Word files is application and the subtype is msword. Together, the complete MIME type is application/msword.
All MIME type information is stored in a database. The MIME database is located in the directory /usr/share/mime/ . The MIME database contains a large number of common MIME types, stored in the file /usr/share/mime/packages/freedesktop.
Currently, there are ten registered types: application, audio, example, font, image, message, model, multipart, text, and video.
Use file
. Examples:
> file --mime-type image.png
image.png: image/png
> file -b --mime-type image.png
image/png
> file -i FILE_NAME
image.png: image/png; charset=binary
one of the other tool (besides file) you can use is xdg-mime
eg xdg-mime query filetype <file>
if you have yum,
yum install xdg-utils.noarch
An example comparison of xdg-mime and file on a Subrip(subtitles) file
$ xdg-mime query filetype subtitles.srt
application/x-subrip
$ file --mime-type subtitles.srt
subtitles.srt: text/plain
in the above file only show it as plain text.
file version < 5 : file -i -b /path/to/file
file version >=5 : file --mime-type -b /path/to/file
Try the file
command with -i
option.
-i
option Causes the file command to output mime type strings rather than the more traditional human readable ones. Thus it may say text/plain; charset=us-ascii
rather than ASCII text
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With