|
|
When you logon to the Windows NT environment, you will see a window called the 'Program Manager'. This window has several 'Program Groups', all of which are represented by small, identical icons. With the mouse, Double-click on the icon labeled 'Main'.
This will open up another "child" window, 'Main', that contains several different icons, including the File Manager, Control Panel, Print Manager, etc...
To start the DOS Prompt, Double-Click on the MS DOS (Command Prompt) icon.This will bring up a new window with a black background. This is the DOS Prompt window. The first thing that you will see, will look something like the following:
Windows(R) NT(TM) (C) Copyright 1985-1995 Microsoft Corp. Z:\>The first two lines is just a message telling the user about the Operating System. It will appear every time a command prompt is started.
The actual prompt is just the '>' symbol. Everything previous to that symbol is just the current directory in which you are working. In the previous case, the current directory is just the Z drive root directory "z:\".
Changing drives in DOS is very easy. Simply type the letter of the drive you want to go to, a colon <:> and <Enter>.
For example, to change from the Z drive to the H drive:
z:\> h:<Enter>
h:\>
The DOS operating system keeps track of files in a simple system of directories. In order to run a program, you need to know the directory in which it is located.
For example, if you are working on your homework assignment, and you wish to run it from the DOS Prompt, type CD (which stands for Change Directory) and then the directory where your program is located.
It should look something like this:z:\> cd bc5<Enter>
z:\bc5\> cd hw1<Enter>
z:\bc5\hw1\>From this point, you can now run any program in this directory. To find out what is in the current directory, see the section below
- Use dir to display a detailed list of the contents of a directory.
- Use dir |more ("dir" followed by the vertical line character and the word "more") if the listing is too long to fit on one screen.
- Use dir /w to display filenames in a compact ("wide") format
Before you start moving things around in DOS, make sure you have a firm grasp on the basics. Once you have mastered the above topics, you will be ready for this section.
The Difference between Copying and Moving:
First of all, you should understand that "copying" a file, and "moving" a file, are virtually identical, except that, as you might suspect, moving a file from one location to another suggests that it will no longer be in the original location, while copying it will result in a copy of the file being in two different places.
This becomes important when you are moving/copying files. For example, if you move a file from your Z drive to the A drive, just to make a backup copy, the original will be deleted and your only copy will be on the Floppy disk (A). This may make it difficult to work on a program if one of the files is on the floppy, while the others are in your Z drive. So, be careful.
Copying Files
To be on the safe side, make sure you know the full path to the file. The "path" is the location of the file. The "full path" is the non-relative location of the file. A good set of examples of full paths would be the underlined examples in the section above on changing directories.
Once you know the full path, you can copy files to and from any directory, regardless of your current directory location.
So, let's say that we have a file in z:\bc5\hw1 called something clever like hw1.cpp that we want to copy to the z:\submit directory (this is called submitting your file). At any prompt, you could type:
copy z:\bc5\hw1\hw1.cpp z:\submit\
and this would copy the file from the hw1 directory to the submit directory.
This example is what we call non-relative copying since it doesn't rely on what directory you happen to be in when you execute the command and this is because we fully specified the path of the source (z:\bc5\hw1\hw1.cpp) and the target (z:\submit\).
In fact, the general form of the copy command is very simple: copy [source] [target].
This leads us to a fancier way of doing copying called relative copying. The idea here is to save typing time and effort. Let us say, using the above example, we were already in the hw1 directory. Then we could type something like this:
z:\bc5\hw1>copy hw1.cpp z:\submit\
which saves you the effort of typing the path. Likewise, if you were in the submit directory, you might type:
z:\submit\>copy z:\bc5\hw1\hw1.cpp
Note that in each case where the path was not specified, DOS defaulted to the directory you were in when you executed the command. Logical, eh?
Also note that the source and target directories can be the same. There is nothing wrong with copy old.cpp new.cpp if you want the files to be in the same directory. Here I have done two things at once: I have made a copy and I have renamed the second copy. This is perfectly legit in combination with using other directories, too.
One should be careful that one does not overwrite files using the copy (or move) command.
If DOS finds a file in the target directory with the same name as the target you specify in the command, it will overwrite the file without prompting. Take a moment to think about the proposed command before you do it. It is very easy to just casually overwrite the file with a careless command and much data has been lost this way. If you are not sure you can always do a dir of the target directory before you do the copy.
Moving Files
Moving files is identical to copying files, using the move command just as if you were using the copy command. Like copy, the syntax is: move [source] [target].
Just remember that file will no longer be the source directory when you are done!
Command Editing
After you have typed a command and before you press <Enter>, you can edit the command in two ways. The first way is to press the Backspace (<---) Key, which will erase characters in the command starting from the right and working left.
The other method is to press the Left Arrow Key (it is right below the Delete Key and looks like the arrow on the Backspace Key except that it is shorter) until you move far enough back along the line to where the mistake is. At this point the line editor is in overwrite mode, which means that if you start typing now, you will type over any characters to the right of where you are. If you want to insert characters instead, just press the Insert Key. The Insert Key is right above the Delete Key and just to the right of the Backspace Key.
At any time you want you can switch back and forth between overwrite mode and insert mode and you can go left or right using the Left Arrow Key or the Right Arrow Key. You can even use the Backspace Key in the middle of the line if you want. Very flexible, eh? :)
Command Stack
DOS has a what is usually called a command stack or command history which is of great use when you are doing the same commands over and over. To access the stack, one uses the Up Arrow Key (backward) and the Down Arrow Key (forward) in much the same way as you use the "Back" and "Forward" buttons in a Web browser. Here is an example:
z:\> cd bc5<Enter>
z:\bc5\> cd hw1<Enter>
z:\bc5\hw1\>At this point if you were to press the Up Arrow Key once, z:\bc5\>cd hw1 would appear on the screen. You can then edit the command as above or just press <Enter>. Or, if you press the Up Arrow Key twice, z:\>cd bc5 would appear. The Down Arrow Key works the same way, moving you forward in the list of commands instead of back. This being one of those sorts of things that is obvious when seen, but hard to describe, it is suggested that you play around with the Up and Down Keys to get familiar with them. They will save you lots of time and typing!
Note: For a more detailed and interactive command list, type "help" at the command prompt at any time. You can also get more help from the Lab Assistants on duty.
FINAL WARNING: Some of the following commands are extremely dangerous and you may destroy your files and data very easily without intending to! Be Careful!
- APPEND
- Allows programs to open data files in specified directories as if they were in the current directory.
- CD
- Displays the name of or changes the current directory.
- CHDIR
- Displays the name of or changes the current directory.
- CLS
- Clears the screen.
- COPY
- Copies one or more files to another location.
- DATE
- Displays or sets the date.
- DEL
- Deletes one or more files.
- DELTREE
- Deletes a directory and all the files and subdirectories in it.
- DIR
- Displays a list of files and subdirectories in a directory.
- EDIT
- Starts MS-DOS Editor, which creates and changes ASCII files.
- ERASE
- Deletes one or more files.
- EXIT
- Quits the COMMAND.COM program (command interpreter) and goes back to Windows.
- FIND
- Searches for a text string in a file or files.
- FORMAT
- Formats a disk for use with MS-DOS.
- HELP
- Provides complete, interactive Help information for MS-DOS commands.
- MD
- Creates a directory.
- MKDIR
- Creates a directory.
- MORE
- Displays output one screen at a time.
- MOVE
- Moves one or more files. Also renames files and directories.
- Prints a text file while you are using other MS-DOS commands.
- RD
- Removes a directory.
- REN
- Renames a file or files.
- RENAME
- Renames a file or files.
- REPLACE
- Replaces files.
- RMDIR
- Removes a directory.
- TIME
- Displays or sets the system time.
- TREE
- Graphically displays the directory structure of a drive or path.
- TYPE
- Displays the contents of a text file.
- XCOPY
- Copies files (except hidden and system files) and directory trees.
Once you are in DOS, simply type help<Enter> at the command prompt, and a helpful list of commands will appear. To get help with a specific command, type help [command]<Enter> for detailed information about the command.
Many other programs also allow access to their help files from DOS. To access these help files, use the "/?" switch. If a program is equipped with this ability, the help files will be displayed.
For Example: To use the DOS help for the "edit" command, typez:\> edit /?<Enter>
Usable with most common DOS commands are two wildcard symbols, the '*' and the '?'. As an example, I will be using the DIR command, but keep in mind that the same concepts can be readily extended to commands such as COPY, DEL, REN and so on. The general idea is that wildcards are like jokers in a pack of cards - you use them as substitutes for one or more other cards, or in our case, letters in filenames.
The first wildcard is the '*' or asterisk. It stands for anything following it up to the dot or the end of the filename, whichever comes first. Thus,
- DIR *.cpp will list all the files ending in .cpp in the current directory.
- DIR h* will list all the files beginning with an h in the current directory (this is the same as DIR h*.*)
- DIR h*.c* will list all the files which begin with an h in the first part of their name AND begin with a c in the second part of their name.
- DIR *.* will list all files in the current directory.
The other wildcard, the '?', is more limited. It substitutes for a single character only. Thus,
- DIR ?.cpp will list all the files that begin with any one letter and ending in .cpp in the current directory.
- DIR h? will list all the files beginning with an h and then followed by any one other letter in the current directory (this is the not the same as DIR h?.*, but rather is all those beginning with h, followed by one letter and nothing after the dot)
- DIR h?.c? will list all the files which begin with an h then one other letter in the first part of their name AND begin with a c then one other letter in the second part of their name.
- DIR ???.* will list all files beginning with any one, two or three letters (but not four or more) before the dot in the current directory.
Play around and experiment - you'll soon get the hang of it.
|
|
||
|
Feedback PIC Lab home |
UCLA Department of Mathematics Program in Computing - PIC Lab 2817 Boelter Hall / 310-825-7267 |
|
|
This page last updated:
June 28, 2001
|
||