mimetype Command Examples in Linux

“mimetype” is a command line utility in Unix-like operating systems that determines the MIME type of a file. MIME (Multipurpose Internet Mail Extensions) types are used to specify the format of a file, such as whether it is a text file, an image, a video, or some other type of content. The “mimetype” command takes a file name as input and outputs the corresponding MIME type of that file. This information is useful for various purposes, such as determining the appropriate application to open a file with, or determining the format of a file for further processing.

The mimetype command uses a database of known file extensions and MIME types to determine the MIME type of a file. The database is updated regularly and new file formats and MIME types can be added as needed. Using “mimetype” is a simple and efficient way to determine the MIME type of a file, especially for use in scripts and automation tasks. The tool can also be useful for troubleshooting issues with file formats and for determining the appropriate format for a file before it is transferred or processed.

mimetype Command Examples

1. Print the MIME type of a given file:

# mimetype path/to/file

2. Display only the MIME type, and not the filename:

# mimetype --brief path/to/file

3. Display a description of the MIME type:

# mimetype --describe path/to/file

4. Determine the MIME type of stdin (does not check a filename):

# some_command | mimetype --stdin

5. Display debug information about how the MIME type was determined:

# mimetype --debug path/to/file

6. Display all the possible MIME types of a given file in confidence order:

# mimetype --all path/to/file

7. Explicitly specify the 2-letter language code of the output:

# mimetype --language path/to/file
Related Post