Sometimes you have a file, which you have no idea what type of data is contained in it. Perhaps it was originally saved incorrectly or had no extension provided. A simple way to determine the data type, is to use the
file command. For example, if I created a simple text file in vi called ‘test’, and used the command
file test in terminal it would output
test: ASCII text.
Big deal, right? However this command could be very useful if I had a friend send me the same text file but instead of saving it as ‘test’ they saved it incorrectly as ‘test.jpg’. Now when I run the command
file test, the terminal correctly outputs
test: ASCII text, and gives me the needed information about what type of data is actually saved in the file.
Next time you have a mystery file, try this command. It might save you some headaches.