|
|
Let's discuss MS-DOS commands from COMMAND.COM. It's a command processor which works as an interface between you, the user, and DOS. It basically interprets what you have typed at the DOS prompt and processes them. Commands can be categorized into INTERNAL (memory resident) and EXTERNAL (utilities / programs) types.
INTERNAL commands
[ Top ]
Internal commands are memory resident commands.
They are resident in the memory when the COMMAND.COM is loaded in the boot
up process. Table 1 below shows the list of internal commands.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
External commands are MS-DOS utilities / programs. These are the .EXE or .COM programs located on your hard drive. They are normally placed under C:\DOS, the default directory. MS-DOS will load external commands if and only if you instruct to execute them at the DOS prompt and /or in a batch program.
Click here to view the brief description of external commands.
Input/Output Redirection
and Filter Commands [ Top ]
So far, you might have learned how to use some commands in their standard form, e.g. to display the content of a text file, to view a directory listing or to view the tree structure of directories. You can view the output directly on the screen.
Using MS-DOS command in standard form, you type in your instruction at the command prompt, through the keyboard. It's a standard input. Then, MS-DOS will process your input and display the result on the screen. It's a standard output. Up to this point, the job is simply done.
Now, if you want to record a directory listing for further reference or get a hard copy immediately, you need to instruct MS-DOS not to display the result on the screen but to save it to a file or print it out directly. It's called output redirection.
On the other hand, if you want to process a job by using data on an existing file, you need to instruct MS-DOS to use data from a given file. It's called input redirection.
In some cases, moreover, you may need to process a job by executing more than one command. By the way, the output from the first command will not be displayed on the screen but to be redirected into the input of the next command. It involves both output and input redirection. The logical connection betwwen these two commands is called piping.
Piping is associated with filter commands: find, sort and more. "They are called filter commands because they work much like a filter in a water system, which takes incoming water, changes it in some way, and sends it along the system (a good explanation from Van Wolverton's Running MS-DOS)." The application of these filter commands are listed as follow. They can be used simply in an input redirection or through a logical piping connection.
| > | Redirects standard output of a command or program
to a device or a file.
[Output redirection] |
MS-DOS will create the named file if it does not exist or overwrite
it (without prompting to confirm) if it already exists.
|
| >> | Adds standard output of a command or program to
a file.
[Output redirection] |
MS-DOS will create the named file if it does not exist.
|
|
|
Feeds data from a file as the input of a command
or program. (i.e. to read in input from a named file)
[Input redirection] |
|
| | | Feeds the output of a command or program directly
into the input of a filter command.
[Piping] |
|
This section will demonstrate those commands
frequently asked by the students. Before I continue, let me advise you
that don't try to hard memorise all the examples
from this paper only but to practise on the computer until you fully understand
the concepts.
|
|
|
|
|
|
| (1) C:\>DIR dos\*.com > comfile.txt |
|
| (2) C:\>TYPE readme.txt > prn |
|
|
|
|
| (3a) C:\>PATH /?
> path.hlp
(3b) C:\>APPEND /? >> path.hlp |
|
|
|
|
|
|
| (4) C:\>MORE < c:\dos\readme.txt |
|
|
|
|
| (5) C:\>SORT /R <
phone1.txt >sort_ph.txt
|
|
| (6) C:\>SORT < phone2.txt > prn |
|
|
|
|
| (7) C:\>DIR | FIND /C "04-16-00" |
|
| (8) C:\>FIND /I "marketing" phone3.txt | SORT |
|