cmdxray / commands / file

What does file do?

identify a file's type by inspecting its contents, not its name.

▸ Explain your own file command →

file examples, explained

$ file /bin/ls

  • fileidentify a file's type by inspecting its contents, not its name
  • /bin/lsan argument passed to the command

$ file -i document.pdf

  • fileidentify a file's type by inspecting its contents, not its name
  • -iprint a MIME type string instead of human-readable text
  • document.pdfan argument passed to the command

$ file -b image.png

  • fileidentify a file's type by inspecting its contents, not its name
  • -bbrief — don't print the file name, just the type
  • image.pngan argument passed to the command

file flags & options

-bbrief — don't print the file name, just the type
-iprint a MIME type string instead of human-readable text
-zlook inside compressed files
-Lfollow symlinks
-sread block/character special files (devices) too
-kkeep going — report all matches, not just the first
--mimeprint the MIME type
--mime-typeprint only the MIME type (e.g. text/plain)

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.