.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "MIMETYPE 1p" .TH MIMETYPE 1p "2020-10-31" "perl v5.30.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" mimetype \- Determine file type .SH "SYNOPSIS" .IX Header "SYNOPSIS" mimetype [options] [\-] files .SH "DESCRIPTION" .IX Header "DESCRIPTION" This script tries to determine the mime type of a file using the Shared MIME-info database. It is intended as a kind of \fI\f(BIfile\fI\|(1)\fR work-alike, but uses mimetypes instead of descriptions. .PP If one symlinks the \fIfile\fR command to \fImimetype\fR it will behave a little more compatible, see \*(L"\-\-file\-compat\*(R". 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. .PP For naming switches I followed the manpage of \fBfile\fR\|(1) version 4.02 when possible. They seem to differ completely from the spec in the \&'utilities' chapter of \s-1IEEE\s0 Std 1003.1\-2001 (\s-1POSIX\s0). .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-a\fR, \fB\-\-all\fR" 4 .IX Item "-a, --all" Show output of all rules that match the file. .Sp \&\s-1TODO:\s0 this method now just returns one match for each method (globs, magic, etc.). .IP "\fB\-b\fR, \fB\-\-brief\fR" 4 .IX Item "-b, --brief" Do not prepend filenames to output lines (brief mode). .IP "\fB\-\-database\fR=\fImimedir\fR:\fImimedir\fR:..." 4 .IX Item "--database=mimedir:mimedir:..." Force the program to look in these directories for the shared mime-info database. The directories specified by the basedir specification are ignored. .IP "\fB\-d\fR, \fB\-\-describe\fR" 4 .IX Item "-d, --describe" Print file descriptions instead of mime types, this is the default when using \*(L"\-\-file\-compat\*(R". .IP "\fB\-D\fR, \fB\-\-debug\fR" 4 .IX Item "-D, --debug" Print debug information about how the mimetype was determined. .IP "\fB\-f\fR \fInamefile\fR, \fB\-\-namefile\fR=\fInamefile\fR" 4 .IX Item "-f namefile, --namefile=namefile" Read the names of the files to be examined from the file 'namefile' (one per line) before the argument list. .IP "\fB\-\-file\-compat\fR" 4 .IX Item "--file-compat" Make mimetype behave a little more \fBfile\fR\|(1) compatible. This is turned on automatically when you call mimetype by a link called 'file'. .Sp A single '\-' won't be considered a separator between options and filenames anymore, but becomes identical to \*(L"\-\-stdin\*(R". ( 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. .IP "\fB\-F\fR \fIstring\fR, \fB\-\-separator\fR=\fIstring\fR" 4 .IX Item "-F string, --separator=string" Use string as custom separator between the file name and its mimetype or description, defaults to ':' . .IP "\fB\-h\fR, \fB\-\-help\fR" 4 .IX Item "-h, --help" .PD 0 .IP "\fB\-u\fR, \fB\-\-usage\fR" 4 .IX Item "-u, --usage" .PD Print a help message and exits. .IP "\fB\-i\fR, \fB\-\-mimetype\fR" 4 .IX Item "-i, --mimetype" Use mime types, opposite to \*(L"\-\-describe\*(R", this is the default when _not_ using \*(L"\-\-file\-compat\*(R". .IP "\fB\-L\fR, \fB\-\-dereference\fR" 4 .IX Item "-L, --dereference" Follow symbolic links. .IP "\fB\-l\fR \fIcode\fR, \fB\-\-language\fR=\fIcode\fR" 4 .IX Item "-l code, --language=code" The language attribute specifies a two letter language code, this makes descriptions being outputted in the specified language. .IP "\fB\-M\fR, \fB\-\-magic\-only\fR" 4 .IX Item "-M, --magic-only" 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. .IP "\fB\-N\fR, \fB\-\-noalign\fR" 4 .IX Item "-N, --noalign" Do not align output fields. .IP "\fB\-\-output\-format\fR" 4 .IX Item "--output-format" If you want an alternative output format, you can specify a format string containing the following escapes: .Sp .Vb 3 \& %f for the filename \& %d description \& %m mime type .Ve .Sp Alignment is not available when using this, you need to post-process the output to do that. .IP "\fB\-\-stdin\fR" 4 .IX Item "--stdin" Determine type of content from \s-1STDIN,\s0 less powerful then normal file checking because it only uses magic typing. This will happen also if the \s-1STDIN\s0 filehandle is a pipe. .Sp To use this option IO::Scalar needs to be installed. .IP "\fB\-v\fR, \fB\-\-version\fR" 4 .IX Item "-v, --version" Print the version of the program and exit. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" .IP "\s-1XDG_DATA_HOME\s0" 4 .IX Item "XDG_DATA_HOME" .PD 0 .IP "\s-1XDG_DATA_DIRS\s0" 4 .IX Item "XDG_DATA_DIRS" .PD These variables can list base directories to search for data files. The shared mime-info will be expected in the \*(L"mime\*(R" sub directory of one of these directories. If these are not set, there will be searched for the following directories: .Sp .Vb 3 \& $HOME/.local/share/mime \& /usr/local/share/mime \& /usr/share/mime .Ve .Sp See also the \*(L"\s-1XDG\s0 Base Directory Specification\*(R" .SH "FILES" .IX Header "FILES" The base dir for all data files is determined by two environment variables, see \*(L"\s-1ENVIRONMENT\*(R"\s0. .IP "\fIBASE/mime/packages/SOURCE.xml\fR" 4 .IX Item "BASE/mime/packages/SOURCE.xml" All other files are compiled from these source files. To re-compile them use \fB\fBupdate\-mime\-database\fB\|(1)\fR. .IP "\fIBASE/mime/globs\fR" 4 .IX Item "BASE/mime/globs" Compiled information about globs. .IP "\fIBASE/mime/magic\fR" 4 .IX Item "BASE/mime/magic" Compiled information about magic numbers. .IP "\fIBASE/mime/MEDIA/SUBTYPE.xml\fR" 4 .IX Item "BASE/mime/MEDIA/SUBTYPE.xml" Descriptions of a mimetype in multiple languages, used for the \&\*(L"\-\-describe\*(R" switch. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" 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. .PP 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. .SH "TODO" .IX Header "TODO" 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. .SH "BUGS" .IX Header "BUGS" If you find bugs, please file them in our Github issue tracker at . .PP \&\fBmimetype\fR 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 \fBfile\fR\|(1). Possibly a subclass should be made for this one day. .SH "AUTHOR" .IX Header "AUTHOR" Jaap Karssenberg Maintained by Michiel Beijen .SH "COPYRIGHT" .IX Header "COPYRIGHT" 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. .PP This program is distributed in the hope that it will be useful, but \s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE.\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBfile\fR\|(1), \&\fBupdate\-mime\-database\fR\|(1), \&\fBFile::MimeInfo\fR\|(3),