Common DOS Commands
——dir
Earlier we said that under DOS we use typed commands to direct the computer to work. But if we type whatever we want to say into the computer, will it understand?
Obviously that won't work. A computer under DOS can only understand the meanings of certain special English commands. Only if you type those commands will the computer obey your instructions; otherwise it will foolishly say: “Bad command or file name.” That means it doesn't understand what you're saying. So then, what commands are there under DOS?
DOS commands are divided into internal commands and external commands. Internal commands are loaded into memory together with command.com, while external commands are separate executable files, one by one.
The internal commands are all contained in the command.com file in the root directory. Each time the computer starts, it reads this file into memory. In other words, while the computer is running, these internal commands all reside in memory, and you can't see these internal commands with dir. External commands, on the other hand, are stored on disk as independent files, each with the extension com or exe. They do not stay resident in memory; they are only loaded into memory when the computer needs them.
Let's first look at a few of the most commonly used commands, so that we can gain a deeper understanding of DOS commands. The most frequently used command under DOS is none other than the dir command. dir is an abbreviation of the English word directory, and it is mainly used to display the files and subdirectories in a directory.
We can try typing dir after the prompt, then press the Enter key. Uppercase or lowercase doesn't matter. If you type it wrong, you can press the Backspace key to correct it. If there are many files or subdirectories in your current directory, you may find that before you can see the contents clearly, they scroll past in a flash.
Don't worry. If you want to see it clearly, that's easy enough. The dir command can take parameters. Try typing dir/p. Look, now after displaying one screenful of contents, the computer stops.
Did you see the last line of English? It means: if you've finished reading this screen, just press any key to see the next screen. So press a key and try it. Any key will do. Well, did it change to the next screen? Pretty convenient, isn't it?
If you still think using dir/p for paged display is too troublesome, try this command instead. Type dir/w from the keyboard and see. This time all the files are displayed on one screen, but it seems something is missing. It turns out the file sizes and creation times have been omitted. If you only want to know what files and subdirectories are in the directory, and don't care about the files' creation times and sizes, then using dir/w to display them in short format is a good choice.
The dir command can not only see what files are in a directory, it can also view information for a certain file in the directory. For example, typing dir abc means viewing information for the file abc in the current directory, including its size and creation time.
If after executing dir abc, the display shows “File not found.”, that means there is no file named abc in the current directory, so the dir command can also be used to search for files. For example, to check whether there is a file called win.com in the current directory, just type dir win.com.
The dir command can not only search for and display one specific file, it can also display a class of files. For example, if you type dir *.bat, what is displayed will be all files whose extension is bat. Look at the figure below.
So what does the * here mean? In DOS commands, when * appears in a filename, it means any character. For example, A.* represents all files whose primary filename is A and whose extension can be anything. Then dir a.* displays all files whose primary filename is a. What result will appear if you use dir A*.*? The result is that all files whose primary filename begins with A are displayed. Going a little further, what does dir *.* mean? Here both the primary filename and the extension can be anything, so that represents all files. Therefore, this has the same effect as simply typing dir.
Because * can stand in for any character, we call it a wildcard. In fact, * is not the only wildcard. Now let's look at another wildcard----?.
What is the difference between the ? wildcard and *? * can replace multiple characters in a filename, while ? can only replace a single character in a filename. For example, a*.* represents all files whose primary filename begins with a, while a?.* represents all files whose primary filename has only two characters and whose first character is a. Likewise, a??.* represents all files whose primary filename has only three characters and whose first character is a.
There is another difference between the two. Once * appears in a filename, all characters after it have no effect. For example, A*.* and a*b.* are no different at all, but A*.* and A*.com are different, because there is a separator between them, and the effect of * cannot go beyond the separator.
In not going beyond the separator, ? and * are the same. However, whether ? appears in the primary filename or the extension, the characters after it still have an effect. For example, a?.bat and a?b.bat mean different things. The former represents all files whose extension is bat and whose primary filename has two characters with the first character being a; the latter represents all files whose extension is bat and whose primary filename has three characters, with the first character being a and the third character being b.
Finally, let me add one more point; I almost forgot this little issue. When using wildcards, at most one * can appear in the primary filename and at most one * in the extension, but ? can appear multiple times as long as it does not exceed the length of the primary filename and extension. For example, these three filenames are all valid: a???.b??、 a????b?.?c? and ??a?b??c.??d.
To sum up, the biggest use of the dir command is to let you know exactly what is on the disk and how much storage space is left. One last little tip: if you want to know what is on drive A, you don't have to type a: first to switch the current drive to A and then type dir. You can directly type dir a:. If you don't believe it, try it yourself—but don't forget to insert a floppy disk!
——dir
Earlier we said that under DOS we use typed commands to direct the computer to work. But if we type whatever we want to say into the computer, will it understand?
Obviously that won't work. A computer under DOS can only understand the meanings of certain special English commands. Only if you type those commands will the computer obey your instructions; otherwise it will foolishly say: “Bad command or file name.” That means it doesn't understand what you're saying. So then, what commands are there under DOS?
DOS commands are divided into internal commands and external commands. Internal commands are loaded into memory together with command.com, while external commands are separate executable files, one by one.
The internal commands are all contained in the command.com file in the root directory. Each time the computer starts, it reads this file into memory. In other words, while the computer is running, these internal commands all reside in memory, and you can't see these internal commands with dir. External commands, on the other hand, are stored on disk as independent files, each with the extension com or exe. They do not stay resident in memory; they are only loaded into memory when the computer needs them.
Let's first look at a few of the most commonly used commands, so that we can gain a deeper understanding of DOS commands. The most frequently used command under DOS is none other than the dir command. dir is an abbreviation of the English word directory, and it is mainly used to display the files and subdirectories in a directory.
We can try typing dir after the prompt, then press the Enter key. Uppercase or lowercase doesn't matter. If you type it wrong, you can press the Backspace key to correct it. If there are many files or subdirectories in your current directory, you may find that before you can see the contents clearly, they scroll past in a flash.
Don't worry. If you want to see it clearly, that's easy enough. The dir command can take parameters. Try typing dir/p. Look, now after displaying one screenful of contents, the computer stops.
Did you see the last line of English? It means: if you've finished reading this screen, just press any key to see the next screen. So press a key and try it. Any key will do. Well, did it change to the next screen? Pretty convenient, isn't it?
If you still think using dir/p for paged display is too troublesome, try this command instead. Type dir/w from the keyboard and see. This time all the files are displayed on one screen, but it seems something is missing. It turns out the file sizes and creation times have been omitted. If you only want to know what files and subdirectories are in the directory, and don't care about the files' creation times and sizes, then using dir/w to display them in short format is a good choice.
The dir command can not only see what files are in a directory, it can also view information for a certain file in the directory. For example, typing dir abc means viewing information for the file abc in the current directory, including its size and creation time.
If after executing dir abc, the display shows “File not found.”, that means there is no file named abc in the current directory, so the dir command can also be used to search for files. For example, to check whether there is a file called win.com in the current directory, just type dir win.com.
The dir command can not only search for and display one specific file, it can also display a class of files. For example, if you type dir *.bat, what is displayed will be all files whose extension is bat. Look at the figure below.
So what does the * here mean? In DOS commands, when * appears in a filename, it means any character. For example, A.* represents all files whose primary filename is A and whose extension can be anything. Then dir a.* displays all files whose primary filename is a. What result will appear if you use dir A*.*? The result is that all files whose primary filename begins with A are displayed. Going a little further, what does dir *.* mean? Here both the primary filename and the extension can be anything, so that represents all files. Therefore, this has the same effect as simply typing dir.
Because * can stand in for any character, we call it a wildcard. In fact, * is not the only wildcard. Now let's look at another wildcard----?.
What is the difference between the ? wildcard and *? * can replace multiple characters in a filename, while ? can only replace a single character in a filename. For example, a*.* represents all files whose primary filename begins with a, while a?.* represents all files whose primary filename has only two characters and whose first character is a. Likewise, a??.* represents all files whose primary filename has only three characters and whose first character is a.
There is another difference between the two. Once * appears in a filename, all characters after it have no effect. For example, A*.* and a*b.* are no different at all, but A*.* and A*.com are different, because there is a separator between them, and the effect of * cannot go beyond the separator.
In not going beyond the separator, ? and * are the same. However, whether ? appears in the primary filename or the extension, the characters after it still have an effect. For example, a?.bat and a?b.bat mean different things. The former represents all files whose extension is bat and whose primary filename has two characters with the first character being a; the latter represents all files whose extension is bat and whose primary filename has three characters, with the first character being a and the third character being b.
Finally, let me add one more point; I almost forgot this little issue. When using wildcards, at most one * can appear in the primary filename and at most one * in the extension, but ? can appear multiple times as long as it does not exceed the length of the primary filename and extension. For example, these three filenames are all valid: a???.b??、 a????b?.?c? and ??a?b??c.??d.
To sum up, the biggest use of the dir command is to let you know exactly what is on the disk and how much storage space is left. One last little tip: if you want to know what is on drive A, you don't have to type a: first to switch the current drive to A and then type dir. You can directly type dir a:. If you don't believe it, try it yourself—but don't forget to insert a floppy disk!

