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.
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 in Code Listing 7.7. Unfortunately, you can’t tell by looking if it’s definitive information or a guess, but if it’s terse (as in the second response), take it with a grain of salt.
[ejr@hobbes ejr]$ file /usr/bin/pico /usr/bin/pico: ELF 32-bit LSB executable, → Intel 80386, version 1, dynamically ld [ejr@hobbes ejr]$ file temp.htm temp.htm: ASCII text [ejr@hobbes ejr]$ |