utility

file — external utility

Classifies files using metadata and content signatures. -b omits the filename and --mime-type reports MIME type. Detection is heuristic, not a security guarantee, and depends on the installed magic database. Validate actual format separately. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): text/plain.

Formal Syntax & Structure

bash syntaxbash
file [-b] [--mime-type] [--] FILE...

Parameters & Attributes

NameTypeDescription
FILEpathFile to classify.

Return Value

exit status

Zero on successful operation; nonzero on errors.

Working Example

Example Snippetbash
printf 'sample text\n' > sample.txtfile -b --mime-type -- sample.txt
Bash Reference