Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement
next up previous contents index
Next: Helping Yourself Up: Unix Commands Previous: Unix Commands

A Typical Unix Command

The first command to know is cat . To use it, type cat, and then return :

If you now have a cursor on a line by itself, you've done the correct thing. There are several variances you could have typed--some would work, some wouldn't.

  • If you misspelled cat, you would have seen

    Thus, the shell informs you that it couldn't find a program named ``ct'' and gives you another prompt to work with. Remember, Unix is case sensitive: CAT is a misspelling.

  • You could have also placed whitespace before the command, like this:gif

    This produces the correct result and runs the cat program.

  • You might also press return on a line by itself. Go right ahead--it does absolutely nothing.

I assume you are now in cat . Hopefully, you're wondering what it is doing. For all you hopefuls, no, it is not a game. cat is a useful utility that won't seem useful at first. Type anything, and hit return. What you should have seen is:

(The slanted text indicates what the user types.) What cat seems to do is echo the text right back at yourself. This is useful at times, but isn't right now. So let's get out of this program and move onto commands that have more obvious benefits.

To end many Unix commands, type gif. is the end-of-file character, or EOF for short.  Alternatively, it stands for end-of-text, depending on what book you read. I'll refer to it as an end-of-file. It is a control character that tells Unix programs that you (or another program) is done entering data. When cat sees you aren't typing anything else, it terminates.

For a similar idea, try the program sort.  As its name indicates, it is a sorting program. If you type a couple of lines, then press , it will output those lines in a sorted order. By the way, these types of programs are called filtersfilter, because they take in text, filter it, and output the text slightly differently. (Well, cat is a very basic filter and doesn't change the input.) We will talk more about filters later.


next up previous contents index
Next: Helping Yourself Up: Unix Commands Previous: Unix Commands

Converted on:
Mon Apr 1 08:59:56 EST 1996
Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.