% more .cshrcwill show you the contents of your ".cshrc" file. If this is longer than 1 page, you'll see "MORE" at the bottom of the screen (assuming all goes well, it knows what kind of terminal you have, etc.). Usually it will also give you a percentage. This is how far through the file you are. At this point, you can hit <return> to advance by a single line, "d" to advance by a few lines (11?) and <space> to advance 1 page. There are other options, which you can see by hitting "h" at the "MORE" prompt. When you get the shell prompt back, you're finished with the file.
"What is all this nonsense in my .cshrc file?" you ask. Well "rc", which stands for "run commands", means it's a file that some program looks at when it first starts up. "cshrc" means it's a run commands file for your shell (csh), and the "." makes it invisible. Each line in the ".cshrc" file is a command. All these commands are executed (just like EXEC'ing a file in ProDOS, or an MS-DOS batch file) whenever the shell (csh) is started up, for example, when you log in. Most of them are not things you'll need to worry about any time soon.
The ".login" file is another sort of setup file. It's a bunch of commands that are executed each time you log in. Now, you may be wondering what the difference is between ".cshrc" and ".login". Well, ".cshrc" is executed each time csh is started up. ".login" is executed each time you log in. It is possible to start up csh several times while logging in only once.
Of course, you can see your ".login" file by typing "more .login". You can also type "cat .login". "cat" and "more" are very similar. The difference is that "cat" just prints a text file, while "more" stops at the end of each page. If you use both "cat" and "more" on a long file, you should be able to see the difference. "more" is good as a text file viewer, while cat is good if you want to do something else with the contents of the file (more on that in a bit).
Another invisible file you might have is ".plan". This is supposed to indicate what you're doing with yourself. If people want information on you, they can ask the computer, and it will print out for them the contents of your ".plan" file. If you have a ".plan" file, you might want to look at it. If not, you can make one using the commands I'll show you shortly.
The real power of Unix begins to become apparent when dealing with I/O redirection. This is what Unix does better than any other operating system I've used. The main symbols to remember here are ">" and "|".
">" is for sending the output of some command to a file. For example, type
% ls > temp1This does an "ls", but, instead of sending the output to the screen, it creates a text file called "temp1" and send the output there. Type "ls" now. There's the file "temp1" in your directory. Now, take a look at what's in temp1 (type "more temp1"). So, temp1 now contains a copy of your directory listing.
">" can be used to redirect the output of almost any command. If you type
% cat .cshrc > temp1then the computer takes what was in ".cshrc" and copies it to "temp1" ... probably. Some systems have an automatic safeguard that prevents you from writing over a file that is already there. If your system has this, you might have seen "temp1: File exists." You can get around this safeguard by "yelling" at the system, typing "cat .cshrc >! temp1". The exclamation point here means "I really mean it!"
This is one way to make a copy of a text file. If you type "more temp1" then you can see that all the nonsense that was in ".cshrc" is now also in "temp1". If you don't have the above-mentioned safeguard need to be careful, though! Notice that the directory listing is not in "temp1" anymore. Using ">" destroys whatever used to be in the output file.
Now, the above situation ("cat .cshrc > temp1") was a case where "cat" is more appropriate than "more". It should be pretty obvious why.
Suppose you want to create a new text file. If it's short, there's an easy way to do this without using an editor. For example, type
% cat > temp2Notice that this time I didn't give "cat" a filename. "cat" will now take its input from the keyboard. So you can type a bunch of stuff, press return a few times ... whatever. When you're done, press return, followed by a <ctrl-D>. Now, type "more temp2". There's what you typed.
">" can be a bit troublesome, since it always erases the output file before it starts. If you don't want to do this, you can use ">>". This is just like ">" except that it appends the output to the end of the file. For example, type
% cat >> temp2Type whatever you want, as before, and <return><ctrl-D> when you're done. Now, type "more temp2". There's what you typed the first time, with what you typed the second time appended to it.
As with ">", ">>" will work with the output of almost any command. For example, if you type "ls >> temp2", then your directory listing gets appended to temp2. You can also type "ls -al >> temp2", of course. Now, try this: create a couple of short text files called "temp1" and "temp2". Then type "cat temp2 >> temp1". Type "more temp1" to see what happened. This, then, is one way to append one text file to another. Another way to do it is to give "cat" 2 filenames as parameters: "cat temp1 temp2 > temp3". If you do something like this, make sure you don't send a file to itself (e.g., don't type "cat temp1 > temp1").
The second major I/O redirection symbol is "|". This is what is called a "pipe", and is probably one of the niftiest features of Unix. Where ">" sends the output of a command to a file, "|" sends the output one one command to the input of another command, just as if the two commands were connected with a "pipe":
input output input output
>[command1]>==================>[command2]>
pipe
The main use of this is with programs called "filters". A filter is a
program that takes text input, changes it in some way, and then prints
it out. One example of this is "sort". "sort" looks at its input,
rearranges the lines in alphabetical order, and then outputs them.
For example, if you type "cat .login" you can see that the lines are probably not in alphabetical order. So, type "cat .login | sort". This takes the output of "cat .login", which is just the contents of the file ".login", and sends it to the "sort" filter. The result is the contents of ".login" with the lines in alphabetical order.
You can, of course, combine all of these. Say you have a long directory, and you want to look at it page by page. Just type "ls | more" or "ls -al | more", etc. If, for some odd reason, you want to look at a sorted version of your .cshrc file page by page, type "cat .cshrc | sort | more". If you want to append a sorted version of your .cshrc file to temp1, type "cat .cshrc | sort >> temp1". Also, "cat .cshrc | more" does essentially the same thing as "more .cshrc". (Actually there are slight differences.)
Another I/O redirection character is "<". It is just the opposite of ">" -- it takes input from a file, instead of sending it to a file. Instead of "cat .cshrc | sort", you could type "sort < .cshrc".
Thus, you now know 3 ways of paging thru a file:
% more fileor
% cat file | moreor
% more < fileand these 3 do nearly the same thing.
One more nice feature is "wildcards", which allow you to tell a program to do something with all files whose names match a certain pattern. The most-used wildcard is "*", which means "zero or more characters". For example, you should now have files named "temp1", "temp2", etc. in your directory. If you wanted to see them all, you could type
% more temp1 temp2 temp3but with wildcards, you could type
% more temp*which does exactly the same thing.
"*" can be used with any command. For example, try
% ls t*