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.
- Is it possible to use
xdg-open
or some other utility to open this file with the default application? - Is there a MIME viewer? E.g., that can display common content types, like
text/plain
andtext/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?
<html><body>
at the start and</body></html>
at the end and open it in a browser.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 ofcase $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.