file

Determine file type.

TL;DR

# Give a description of the type of the specified file. Works fine for files with no file extension:
$ file path/to/file

# Look inside a zipped file and determine the file type(s) inside:
$ file -z foo.zip

# Allow file to work with special or device files:
$ file -s path/to/file

# Don't stop at first file type match; keep going until the end of the file:
$ file -k path/to/file

# Determine the MIME encoding type of a file:
$ file -i path/to/file

Usage

$ file dnspod_ddns
dnspod_ddns: Python script, UTF-8 Unicode text executable
$ file -b dnspod_ddns
Python script, UTF-8 Unicode text executable
$ file --mime-type dnspod_ddns
dnspod_ddns: text/x-python
$ file --mime dnspod_ddns
dnspod_ddns: text/x-python; charset=utf-8
$ file -i dnspod_ddns
dnspod_ddns: text/x-python; charset=utf-8
$ file -b --mime-type dnspod_ddns
text/x-python

$ file update-system.sh
update-system.sh: POSIX shell script, ASCII text executable
$ file --mime-type update-system.sh
update-system.sh: text/x-shellscript