inspect reads a file’s contents to work out what it is, rather than trusting the extension.
It writes nothing and changes nothing.
Arguments
string
required
The file to inspect. Only one at a time.
Options
boolean
default:"false"
Emit machine-readable JSON instead of the human summary.
JSON output
string
required
The path you passed in, unchanged.
number
required
Size on disk, in bytes.
string
Read from the file’s magic bytes. Absent if nothing recognisable was found.
string
The canonical extension for that type, which may differ from the filename.
object
Present only if the file could be decoded as an image.
Spotting a mislabelled file
Because detection ignores the extension, a renamed file gives itself away — the detected type won’t match the name:Using it in a script
--json pairs with jq for quick checks:
inspect exits non-zero if the file can’t be read at all. A file that reads fine but isn’t a
decodable image still exits 0 — image is simply omitted, which is a result rather than an
error.