How to get the mime type of a file from the command line?
Use file --mime-type -b filename
Look at file --help
for more tips.
The great answer on this page can be put in a function or script like so:
Example
$ mime_type.sh /etc/passwd
text/plain
mime_type.sh
function mime_type()
{
file --mime-type -b $*
}
mime_type $*