Linux/Unix – Managing Files..
File management tools include those for splitting, comparing, and compressing files, making backup archives, and tracking file revisions. Other management tools exist for determining the contents of a file, and for changing its timestamp.
Determining File Type and Format
When we speak of a file’s type, we are referring to the kind of data it contains, which may include text, executable commands, or some other data; this data is organized in a particular way in the file, and this organization is called its format. For example, an image file might contain data in the JPEG image format, or a text file might contain unformatted text in the English language or text formatted in the TeX markup language.
The file tool analyzes files and indicates their type and−−if known−−the format of the data they contain. Supply the name of a file as an argument to file and it outputs the name of the file, followed by a description of its format and type. To determine the format of the file `/usr/doc/HOWTO/README.gz’, type:
$ file /usr/doc/HOWTO/README.gz
/usr/doc/HOWTO/README.gz: gzip compressed data, deflated, original
filename, last modified: Sun Apr 26 02:51:48 1998, os: Unix
This command reports that the file `/usr/doc/HOWTO/README.gz’ contains data that has been compressed with the gzip tool. To determine the original format of the data in a compressed file, use the `−z’ option. To determine the format of the compressed data contained in the file `/usr/doc/HOWTO/README.gz’, type:
$ file −z /usr/doc/HOWTO/README.gz
/usr/doc/HOWTO/README.gz: English text (gzip compressed data, deflated,
original filename, last modified: Sun Apr 26 02:51:48 1998, os: Unix)
This command reports that the data in `/usr/doc/HOWTO/README.gz’, a compressed file, is English text.
NOTE: Currently, file differentiates among more than 100 different data formats, including several human languages, many sound and graphics formats, and executable files for many different operating systems.