What are these files?

So in a previous post we talked about the more command. We also saw how if we tried to look at a binary file, we saw

"/usr/bin/more" may be a binary file.  See it anyway?

So now we have a question: Is there a way to find out if a file is a plain text file versus a binary file? Well, this being Linux®… of course there is! It’s called the file command. It uses various tests to try to find out what kind of data is contained within the file. Remember the blog1.txt file from the other post? If we run

Alpha:~ computerlamp$ file blog1.txt

We get:

blog1.txt: ASCII English text

So that means it’s a file we can use the more command on. What if it is a file that ends with .pdf and is still a text file? Well, that’s the magic of the file command. It doesn’t pay attention to the extension (that’s the letters after the dot) but tests the file itself. We can use the file command on any kind of file. Go ahead, try it on anything on your system, see what you get. It just identifies the file, it doesn’t do anything to it.

Leave a Reply

Your email address will not be published. Required fields are marked *