% rm temp1and similarly for temp2 and temp3. BE VERY CAREFUL with "rm". There is no way to "undo" it, and a mis-type can wreak havoc on your files. Using wildcards with rm is an easy way to destroy months of work.
On some systems, rm will always ask you if you want to delete files. This is called "interactive mode". Hit "y" and press <return> to delete; if you type anything else, the file will not be deleted. Even if your system does not do this automatically, you can usually force interactive mode using the "-i" option, e.g.,
% rm -i temp2Just as in ProDOS, Unix allows directories within directories (it also allows one file to act as if it is in 2 different directories by using something called a "link", but I won't tell you how that works yet).
To see what your current directory is, type
% pwd"pwd" stands for "print working directory" and typing it is like typing "PREFIX" by itself in ProDOS. When I type "pwd" I get
/home/symcom/chappelland you should get something similar. The slashes ("/") mean exactly the same thing as they do in ProDOS. (MS-DOS uses a backslash -- "\".) In my case they mean that in the root directory (which is just "/") is a directory called "home", in which is a subdirectory called "symcom", and in "symcom" is a directory called "chappell", which is my HOME directory. Just as in ProDOS, I can change my current directory. The Unix command for this is "cd" for "change directory". For example, to go up one directory level, I can type "cd /home/symcom" (you would type something different, of course). At that point, if I type "pwd" [you are trying this out on your own machine, aren't you?] I get
/home/symcomIf I then type "ls" I get a huge listing showing all the other users of symcom. It takes quite a while to format it, and the first time I did it, I thought the computer had hung.
Now, my home directory ("chappell") is a file in the directory /home/symcom. At this point if I wanted to go back to my home directory, I could type "cd /home/symcom/chappell", but the "cd" command is just like the ProDOS "PREFIX" command: if I don't begin the directory name with a slash, it just adds it on to my current prefix. Thus, I can just type "cd chappell".
Now, there are easier ways to do both of those. "cd" by itself always takes you back to your home directory, so you don't have to worry about getting lost. Now, go back to your home directory ("cd") and type "ls -al". You should see two files with the odd names of "." and "..". These represent the current directory and the next directory up, respectively. Try the following sequence of commands to see what they do:
% cd % pwd % cd .. % pwd % cd .. % pwd % cd . % pwd % cd /var/spool/mail % pwd % ls % cdSo, "cd .." moves up one directory level. "cd ." basically does nothing, since "." represents the current directory ... but "." has other uses.
By the way, the directory "/var/spool/mail" is where the incoming mailboxes are kept on most systems. If you have mail waiting, it will be in the text file /var/spool/mail/YOURNAME, where "YOURNAME" is replaced by your user id. For example, my mail is kept in /var/spool/mail/chappell. To see your mail in its "raw" form, type
% cat /var/spool/mail/YOURNAMEagain, replacing "YOURNAME" with your user id, or
% cd /var/spool/mail % cat YOURNAMEYou can also create your own directories. In ProDOS this is the "CREATE" command, while in Unix, it is "mkdir" for "make directory". For example, if you're not already back to your home directory, type "cd" to get there, and then
% mkdir testNow, type "ls". There is the file "test" in your directory. You may see a slash after the file name, indicating that "test" is a directory. (If you don't see one, try "ls -F".)
Now, create a text file called "temp1" inside subdirectory test. You can do this 2 ways:
% cat > test/temp1or
% cd test % cat > temp1If you haven't already, do a "cd test" to set your working directory to "test". Now, "ls" shows you the contents of "test", while "ls .." shows you the contents of your home directory. Do you see why? You can also type "cat ../.login", and, in general, directory names, including "..", can be used anywhere you use filenames in Unix.
Another special character relating to directories is "~". In the C-shell this refers to your home directory. For example, suppose you typed "cd /var/spool/mail". Then say you wanted to look at your .login file. You could type
% cd % more .loginbut using "~" you wouldn't have to change your working directory. You could just type
% more ~/.loginIn the previous chapter, I showed how "cat" could be used to copy files. However, there is a better way: "cp". Set your working directory to "test" if it isn't already, and type
% cp temp1 temp2Now, typing "ls" you should see that there are 2 files in "test", "temp1" and "temp2". Using "more" or "cat" you can find out that "temp2" is a copy of "temp1". "cp" can also be used if the two files are not in the same directory:
% cp temp1 ~/temp3This creates a copy of temp1 in your home directory, and calls it "temp3". A second way of using "cp" is to specify only a directory as the second parameter:
% cd % cp temp3 testThis does not make a copy of temp3 called test. Rather, since "test" is a directory, it puts a copy of temp3 inside test, and calls it temp3. It is just as if you typed
% cp temp3 test/temp3You can use "more" to check this out.
A command very similar to "cp" is "mv" for "move". It is just like "cp" except that it doesn't leave the original file around. This has some interesting results. Try
% cd test % mv temp3 temp4Now, there is a new file called "temp4" in "test", and the old "temp3" is gone. Thus, "mv" can be used just like the ProDOS "RENAME" command. Just like cp, it can also be used to move a file from one directory to another:
% mv temp4 ~moves temp4 to your home directory.
Now, type "cd" to get back to your home directory. Say you want to get rid of "test". "rm" in its usual form won't delete directories. The command is "rmdir" for "remove directory". But, if you type "rmdir test" the computer should respond by saying that "test" is not empty. In order to delete it, you need to delete its contents first. So, type
% rm test/temp1 % rm test/temp2 % rmdir testand the directory should be gone.