Finding out file types with file

If you come from a Windows, Macintosh, or DOS background, you're probably used to accessing files and being able to see what type of files they are—HTML files, GIFs, documents, or whatever. In UNIX, though, you often can't tell the file type just by listing files or displaying directory contents. That's where file comes in handy, as shown in Code Listing 7.7.

To identify file types with file:

  • file /usr/bin/pico
    At the shell prompt, type file, followed by the path (if necessary) and file name. You'll see output similar to that in Code Listing 7.7.

Tip

Not all files have the "magic" information that makes file work associated with them, but most do. Where they don't, you get a best-guess response, like the second ...

Get Unix: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.