commands
file — classify file kind or content
Classifies a path using metadata and content patterns. Descriptions depend on the implementation and magic database; the result is not a security verdict. Some classification errors do not affect status unless -E is given. Examples assume a fresh chapter files lab.
Formal Syntax & Structure
linux syntaxlinux
file [OPTION]... FILE...Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| -b | option | Omit filename prefix |
| -L | option | Follow symbolic links |
| -E | option | Treat filesystem errors as errors affecting exit status |
| FILE | operand | Path to classify |
Return Value
text and exit status
Prints a classification rather than a Boolean verdict. Some filesystem errors are reported in the classification while status remains 0; use -E when error status is needed and inspect diagnostics.
Working Example
Example Snippetlinux
file -b notes/hello.txt