340 lines
9.0 KiB
HTML
340 lines
9.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of MIMETYPE</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>MIMETYPE</H1>
|
|
Section: User Contributed Perl Documentation (1p)<BR>Updated: 2018-08-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
mimetype - Determine file type
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
mimetype [options] [-] files
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
This script tries to determine the mime type of a file using the
|
|
Shared MIME-info database. It is intended as a kind of <I><A HREF="/cgi-bin/man/man2html?1+file">file</A>(1)</I> work-alike,
|
|
but uses mimetypes instead of descriptions.
|
|
<P>
|
|
|
|
If one symlinks the <I>file</I> command to <I>mimetype</I> it will behave
|
|
a little more compatible, see ``--file-compat''.
|
|
Commandline options to specify alternative magic files are not
|
|
implemented the same because of the conflicting data formats.
|
|
Also the wording of the descriptions will differ.
|
|
<P>
|
|
|
|
For naming switches I followed the manpage of <I><A HREF="/cgi-bin/man/man2html?1+file">file</A></I>(1) version 4.02
|
|
when possible. They seem to differ completely from the spec in the
|
|
'utilities' chapter of <FONT SIZE="-1">IEEE</FONT> Std 1003.1-2001 (<FONT SIZE="-1">POSIX</FONT>).
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>-a</B>, <B>--all</B><DD>
|
|
|
|
|
|
Show output of all rules that match the file.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<FONT SIZE="-1">TODO:</FONT> this method now just returns one match for each
|
|
method (globs, magic, etc.).
|
|
<DT id="2"><B>-b</B>, <B>--brief</B><DD>
|
|
|
|
|
|
Do not prepend filenames to output lines (brief mode).
|
|
<DT id="3"><B>--database</B>=<I>mimedir</I>:<I>mimedir</I>:...<DD>
|
|
|
|
|
|
Force the program to look in these directories for the shared mime-info
|
|
database. The directories specified by the basedir specification
|
|
are ignored.
|
|
<DT id="4"><B>-d</B>, <B>--describe</B><DD>
|
|
|
|
|
|
Print file descriptions instead of mime types, this is the
|
|
default when using ``--file-compat''.
|
|
<DT id="5"><B>-D</B>, <B>--debug</B><DD>
|
|
|
|
|
|
Print debug information about how the mimetype was determined.
|
|
<DT id="6"><B>-f</B> <I>namefile</I>, <B>--namefile</B>=<I>namefile</I><DD>
|
|
|
|
|
|
Read the names of the files to be examined from the file 'namefile'
|
|
(one per line) before the argument list.
|
|
<DT id="7"><B>--file-compat</B><DD>
|
|
|
|
|
|
Make mimetype behave a little more <I><A HREF="/cgi-bin/man/man2html?1+file">file</A></I>(1) compatible. This
|
|
is turned on automatically when you call mimetype by a link
|
|
called 'file'.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
A single '-' won't be considered a separator
|
|
between options and filenames anymore, but becomes identical to ``--stdin''.
|
|
( You can still use '--' as separator, but
|
|
that is not backward compatible with the original file command. )
|
|
Also the default becomes to print descriptions instead of mimetypes.
|
|
<DT id="8"><B>-F</B> <I>string</I>, <B>--separator</B>=<I>string</I><DD>
|
|
|
|
|
|
Use string as custom separator between the file name and its mimetype
|
|
or description, defaults to ':' .
|
|
<DT id="9"><B>-h</B>, <B>--help</B><DD>
|
|
|
|
|
|
|
|
<DT id="10"><B>-u</B>, <B>--usage</B><DD>
|
|
|
|
|
|
|
|
Print a help message and exits.
|
|
<DT id="11"><B>-i</B>, <B>--mimetype</B><DD>
|
|
|
|
|
|
Use mime types, opposite to ``--describe'',
|
|
this is the default when _not_ using ``--file-compat''.
|
|
<DT id="12"><B>-L</B>, <B>--dereference</B><DD>
|
|
|
|
|
|
Follow symbolic links.
|
|
<DT id="13"><B>-l</B> <I>code</I>, <B>--language</B>=<I>code</I><DD>
|
|
|
|
|
|
The language attribute specifies a two letter language code, this makes
|
|
descriptions being outputted in the specified language.
|
|
<DT id="14"><B>-M</B>, <B>--magic-only</B><DD>
|
|
|
|
|
|
Do not check for extensions, globs or inode type, only look at the content
|
|
of the file. This is particularly useful if for some reason you don't trust
|
|
the name or the extension a file has.
|
|
<DT id="15"><B>-N</B>, <B>--noalign</B><DD>
|
|
|
|
|
|
Do not align output fields.
|
|
<DT id="16"><B>--output-format</B><DD>
|
|
|
|
|
|
If you want an alternative output format, you can specify a format string
|
|
containing the following escapes:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
%f for the filename
|
|
%d description
|
|
%m mime type
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Alignment is not available when using this,
|
|
you need to post-process the output to do that.
|
|
<DT id="17"><B>--stdin</B><DD>
|
|
|
|
|
|
Determine type of content from <FONT SIZE="-1">STDIN,</FONT> less powerful then normal file checking
|
|
because it only uses magic typing. This will happen also if the <FONT SIZE="-1">STDIN</FONT> filehandle
|
|
is a pipe.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To use this option IO::Scalar needs to be installed.
|
|
<DT id="18"><B>-v</B>, <B>--version</B><DD>
|
|
|
|
|
|
Print the version of the program and exit.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ENVIRONMENT</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="19"><FONT SIZE="-1">XDG_DATA_HOME</FONT><DD>
|
|
|
|
|
|
|
|
<DT id="20"><FONT SIZE="-1">XDG_DATA_DIRS</FONT><DD>
|
|
|
|
|
|
|
|
These variables can list base directories to search for data files. The shared
|
|
mime-info will be expected in the ``mime'' sub directory of one of these
|
|
directories. If these are not set, there will be searched for the
|
|
following directories:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$HOME/.local/share/mime
|
|
/usr/local/share/mime
|
|
/usr/share/mime
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
See also the ``<FONT SIZE="-1">XDG</FONT> Base Directory Specification''
|
|
<<A HREF="http://freedesktop.org/Standards/basedir-spec">http://freedesktop.org/Standards/basedir-spec</A>>
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>FILES</H2>
|
|
|
|
|
|
|
|
The base dir for all data files is determined by two environment variables,
|
|
see ``<FONT SIZE="-1">ENVIRONMENT''</FONT>.
|
|
<DL COMPACT>
|
|
<DT id="21"><I>BASE/mime/packages/SOURCE.xml</I><DD>
|
|
|
|
|
|
All other files are compiled from these source files. To re-compile them
|
|
use <B></B><A HREF="/cgi-bin/man/man2html?1+update-mime-database">update-mime-database</A><B>(1)</B>.
|
|
<DT id="22"><I>BASE/mime/globs</I><DD>
|
|
|
|
|
|
Compiled information about globs.
|
|
<DT id="23"><I>BASE/mime/magic</I><DD>
|
|
|
|
|
|
Compiled information about magic numbers.
|
|
<DT id="24"><I>BASE/mime/MEDIA/SUBTYPE.xml</I><DD>
|
|
|
|
|
|
Descriptions of a mimetype in multiple languages, used for the
|
|
``--describe'' switch.
|
|
</DL>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>DIAGNOSTICS</H2>
|
|
|
|
|
|
|
|
If a file has an empty mimetype or an empty description,
|
|
most probably the file doesn't exist and the given name
|
|
doesn't match any globs. An empty description can also mean that
|
|
there is no description available in the language you specified.
|
|
<P>
|
|
|
|
The program exits with a non-zero exit value if either the commandline
|
|
arguments failed, a module it depends on wasn't found or the shared
|
|
mime-info database wasn't accessible. See File::MimeInfo for more details.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>TODO</H2>
|
|
|
|
|
|
|
|
The '--all' switch doesn't really show all matches, but only one per
|
|
mime-typing method. This needs to be implemented in the modules first.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
|
|
|
|
If you find bugs, please file them in our Github
|
|
issue tracker at <<A HREF="https://github.com/mbeijen/File-MimeInfo/issues">https://github.com/mbeijen/File-MimeInfo/issues</A>>.
|
|
<P>
|
|
|
|
<B>mimetype</B> doesn't provide a switch for looking inside compressed files
|
|
because it seems to me that this can only be done by un-compressing the file,
|
|
something that defeats the purpose. On the other hand the option should
|
|
exist for strict compatibility with <I><A HREF="/cgi-bin/man/man2html?1+file">file</A></I>(1). Possibly a subclass should be
|
|
made for this one day.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Jaap Karssenberg <<A HREF="mailto:pardus@cpan.org">pardus@cpan.org</A>>
|
|
Maintained by Michiel Beijen <<A HREF="mailto:michiel.beijen@gmail.com">michiel.beijen@gmail.com</A>>
|
|
<A NAME="lbAL"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright (c) 2003, 2012 Jaap G Karssenberg. All rights reserved.
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the same terms as Perl.
|
|
<P>
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but <FONT SIZE="-1">WITHOUT ANY WARRANTY</FONT>; without even the implied warranty of
|
|
<FONT SIZE="-1">MERCHANTABILITY</FONT> or <FONT SIZE="-1">FITNESS FOR A PARTICULAR PURPOSE.</FONT>
|
|
<A NAME="lbAM"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
<I><A HREF="/cgi-bin/man/man2html?1+file">file</A></I>(1),
|
|
<I><A HREF="/cgi-bin/man/man2html?1+update-mime-database">update-mime-database</A></I>(1),
|
|
<I><A HREF="/cgi-bin/man/man2html?3+File::MimeInfo">File::MimeInfo</A></I>(3),
|
|
<<A HREF="http://freedesktop.org/Software/shared-mime-info">http://freedesktop.org/Software/shared-mime-info</A>>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="25"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="26"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="27"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="28"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DT id="29"><A HREF="#lbAF">ENVIRONMENT</A><DD>
|
|
<DT id="30"><A HREF="#lbAG">FILES</A><DD>
|
|
<DT id="31"><A HREF="#lbAH">DIAGNOSTICS</A><DD>
|
|
<DT id="32"><A HREF="#lbAI">TODO</A><DD>
|
|
<DT id="33"><A HREF="#lbAJ">BUGS</A><DD>
|
|
<DT id="34"><A HREF="#lbAK">AUTHOR</A><DD>
|
|
<DT id="35"><A HREF="#lbAL">COPYRIGHT</A><DD>
|
|
<DT id="36"><A HREF="#lbAM">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:19 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|