1

On several distributions of Linux, there is a utility called xdg-open, which opens a file in the default application for that particular file type. E.g., for HTML files, it might open firefox.

A MIME-formatted file contains data and meta-data within a single file, with the meta-data occurring in key/value pairs at the beginning of the file. A MIME-formatted file is very similar to an HTTP response. E.g., here is a MIME-formatted HTML page.

MIME-Version: 1.0
Content-Type: text/html

This is a <em>small</em> HTML document,
located within a MIME file.
  1. Is it possible to use xdg-open or some other utility to open this file with the default application?
  2. Is there a MIME viewer? E.g., that can display common content types, like text/plain and text/html?

It seems to me like there are varying approaches to tracking file meta-data. E.g., there are "sidecar" files, the Mac OS X operating system has filesystem-level "resource forks", Windows uses file extension to determine file type, etc, etc. Wouldn't it be easier if the existing MIME standards were more closely integrated into *nix operating systems?

  • That looks like an email header to me. Why not open it with an email client. Alternatively you could dump it to a file with <html><body> at the start and </body></html> at the end and open it in a browser. – Tigger Mar 7 '17 at 22:19
  • file --mime-type -b /path/to/file will determine the MIME typing of a file. What you do with the response is up to you, but a script with a simple set of case $mimetype in [...] esac should fit the bill. More generally, file is the tool to determine what type of file something is, so that you can deal with it as apropos of its type. – DopeGhoti Mar 7 '17 at 22:41
  • There are arguments to be made against the complexity of MIME, e.g. web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-8873 or web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-7209 – thrig Mar 7 '17 at 22:43

Your Answer

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

Browse other questions tagged or ask your own question.