Although we have been slicing and dicing files for a while now, you still haven’t seen what’s inside one. Two basic types of files exist:
Files that contain text that UNIX can display nicely on-screen Files that contain special codes that look like monkeys have been at the keyboard when you display the files on-screen The first type of files are called text files. The second type is composed of spreadsheet files, database files, program files, and just about everything else. Text editors make text files, as do a few other programs. To display a text file, type this line:
cat eggplant.recipe If you want to see the guts of a file that isn’t named eggplant.recipe, substitute your file’s name. The cat stands for catalog, or maybe catenate — who knows? We’re surprised that the lazy typists didn’t call it something like q . If you try to use cat with a file that doesn’t contain text, your screen looks like a truck ran over it — but you won’t hurt anything. Sometimes the garbage in the file can put your terminal in a strange mode in which characters you type don’t appear or appear as strange Greek squiggles. See Chapter 22 to learn how to "un-strange" your terminal.
If the file is long, the listing goes whizzing by. (You find out how to look at the file one screen at a time in Chapter 7.) To see just the first few lines of the file, you can type this line:
head eggplant.recipe Most versions of the head command display the first ten lines.
Tip You can ask UNIX to guess at what’s in a file, by using the file command. If you type file filename (replacing filename with the name of the file you’re wondering about), UNIX takes a guess at what’s in the file, by looking at it. It says something like this:
letter.to.jordan: ascii text or this unix4d: directory