Linux in a Nutshell, Third Edition
by Ellen Siever, Stephen Spainhour, Jessica P. Hekman, Stephen Figgins
Name
file
Synopsis
file [options] files
Description
Classify the named files according to the type of data they contain. file checks the magic file (usually /usr/share/magic) to identify some file types.
Options
- -b
Brief mode; do not prepend filenames to output lines.
- -c
Check the format of the magic file (files argument is invalid with -c). Usually used with -m.
- -f file
Read the names of files to be checked from file.
- -L
Follow symbolic links. By default, symbolic links are not followed.
- -m file
Search for file types in file instead of /usr/share/magic.
- -n
Flush standard output after checking a file.
- -s
Check files that are block or character special files in addition to checking ordinary files.
- -v
Print the version.
- -z
Attempt checking of compressed files.
Many file types are understood. Output lists each filename, followed by a brief classification such as:
ascii text c program text c-shell commands data empty iAPX 386 executable directory [nt]roff, tbl, or eqn input text shell commands symbolic link to ../usr/etc/arp
Example
List all files that are deemed to be troff/nroff input:
file * | grep roffBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access