File extensions are not necessary on unices, still every tarred, gzipped or bzipped file I encounter has a file extension like .tar, .tar.gz or .tgz.
Is there any special reason for that or is that just convention?
|
|
|
Originally, on unix systems, the extensions on file names were a matter of convention. They allowed a human being to choose the right program to open a file. The modern convention is to use extensions in most cases; common exceptions are:
(These are common cases, not hard-and-fast rules.) Most binary file formats also contain some kind of header that describes properties of the file, and typically allows the file format to be identified through magic numbers. The Sometimes the file extension gives more information than the file format, sometimes it's the other way round. For example many file formats consist of a zip archive: Java libraries ( An advantage of the extension is that it's a lot faster to recognize it than to open the file and look for magic sequences. For example completion of file names in shells is almost always based on the name (mainly the extension), because reading every file in a large directory can take a long time whereas just reading the file names is fast enough for a Tab press. Sometimes changing a file's extension can allow you to say how a file is to be interpreted, when two file formats are almost, but not wholly identical. For example a web server might treat In the case of gzip archives, |
|||
|
|
|
They may not need an extension, but it sure makes identifying them easier in the output of |
|||||
|
|
File extensions are primarily a convention for the humans who use the system. There are tools which do use the filename extension to do things. For example Nautilus shows me a different icon based on the file extension. If I gave you a file called |
|||||
|