Reputation: 28306
I have a file. It's not a text file. What is the logical process and tests one would use to read the file to see what it contains? File structure, vendor, data are all unknown.
Here is a sample of the data:
Upvotes: 1
Views: 5716
Reputation: 7716
In Linux you can use the file
command to determine the type of a given file. file
determines the type of file using a pattern that is taken from a special pattern file named magic
. To determine, it parses the content of the "unknown" file. For more detailed information consult the man page of the file(1)
command and the magic(5)
pattern file.
$ echo "Hello World" > foo.txt
$ mv foo.txt foo
$ file foo
foo: ASCII text
$ echo '#!/bin/bash' > foo
$ file foo
foo: Bourne-Again shell script, ASCII text executable
$ zip foo.zip foo
updating: foo (stored 0%)
$ mv foo.zip foo
$ file foo
foo: Zip archive data, at least v1.0 to extract
Upvotes: 2
Reputation: 49181
The first step is to check against the list of known file signatures also known as magic numbers. Check file
utility on GNU/Linux.
List of file signatures from Wikipedia
Upvotes: 2