1.29 When Is a File Not a File?UNIX differs from most operating systems in that it is file-oriented. The designers of UNIX decided that they could make the operating system much simpler if they treated everything as if it were a file. As far as UNIX is concerned, disk drives, terminals, modems, network connections, etc. are all just files. Some recent versions of UNIX (such as System V Release 4) have gone further: even processes ( 38.1 ) are files. Like waves and particles in quantum physics, the boundary between files and the rest of the world can be extremely fine: whether you consider a disk a piece of hardware or a special kind of file depends primarily on your perspective and what you want to do with it. Therefore, to understand UNIX, you have to understand what files are. A file is nothing more than a stream of bytes - that is, an arbitrarily long string of bytes with no special structure. There are no special file structures, and only a few special file types (for keeping track of disks and a few other purposes). The structure of any file is defined by the programs that use it, and not by the UNIX operating system. [5] You may hear users talk about file headers and so on, but these are defined by the applications that use the files, and not by the UNIX filesystem itself.
UNIX programs do abide by one convention, however. Text files use a single newline character (linefeed) between lines of text, rather than the carriage return-linefeed combination used in DOS or the carriage returns used in the Macintosh. This difference may cause problems when you bring files from other operating systems over to UNIX. DOS files will often be littered with carriage returns (CTRL-m), which are necessary for that operating system but are superfluous for UNIX. These carriage returns will look ugly if you try to edit or print the file and may confuse some UNIX programs. Mac text files will appear to be one long line with no breaks. Of course, you can use UNIX utilities to convert DOS and Mac files for UNIX-see article 1.5 . - |
|