Getting More Information About Filesystem Objects

You might be used to being able to tell what type of file you’re working with by looking at its filename. Typically, a three or four-letter extension gives it away. For example, foo.pdf is a PDF file, logo.png is a graphics file, and foo.txt is a plain-text file. But sometimes there’s no extension, and sometimes the files are named incorrectly.

The file command can help you figure out what type of file you’re working with. Try it out by pointing it at the greetings.txt file you created in the Desktop directory within your home directory:

 $ ​​file​​ ​​~/Desktop/greetings.txt
 /home/brian/Desktop/greetings.txt: ASCII text

The output tells you what’s in the file by looking at its content. Create ...

Get Small, Sharp Software Tools 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.