Chapter 6. Command Prompt

The premise of the command prompt is simple enough: commands are typed, one at a time, at a blinking cursor, and the commands are issued when the Enter key is pressed. After a command has completed, a new prompt is shown, allowing additional commands to be typed.

To open a command prompt window, go to Start Programs Accessories Command Prompt, or go to Start Run and launch cmd.exe.

Some commands are fairly rudimentary, requiring only that you type their name. Other commands are more involved, and can require several options (sometimes called arguments or command-line parameters). For example, the del command (discussed later in this chapter) is used to delete one or more files; it requires that the name of the file be specified after the command, like this:

del /p myfile.txt

Here, myfile.txt is the filename to be deleted, and /p is an extra option used to modify the behavior of del. Now, the fact that this usage is not limited to internal commands (like del) is what makes the command line such an important part of Windows XP's design. For example:

notepad c:foldermyfile.txt

is what Windows executes behind the scenes, by default, when you double-click the myfile.txt icon in Explorer. The Notepad application name is used as a command here; if you type the filename of any existing file at the command prompt, it instructs Windows to launch that file. This works for applications, Windows Shortcuts, batch files, documents, or any other type of file; the only requirement is that the file be located in the current working directory (see the cd command, later in this chapter) or in a folder specified in the path (also discussed later in this chapter).

Wildcards, Pipes, and Redirection

These symbols have special meaning when used with other commands on the command line:

Symbol

Description

*

Multiple-character wildcard, used to specify a group of files.

?

Single-character wildcard, used to specify multiple files with more precision than *.

.

One dot represents the current directory; see "cd."

..

Two dots represent the parent directory; see "cd."

Separates directory names, drive letters, and filenames. By itself, represents the root directory of the current drive.

>

Redirect a command's text output into a file instead of the console window; existing files will be overwritten.

>>

Redirect a command's text output into a file instead of the console window, appending existing files.

<

Directs the contents of a text file to a command's input; use in place of keyboard entry to automate interactive command-line applications.

|

Redirects the output of a program or command to a second program or command (this is called a "pipe").

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset