Finding Out File Types with file

If you come from a Windows or Macintosh 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 filename. You’ll see output similar to that in Code Listing 7.7.

✓ Tip

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

Get Unix Third Edition: 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.