China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 20:12
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Common DOS Commands View 1,351 Replies 0
Original Poster Posted 2003-06-03 00:00 ·  中国 湖南 长沙 电信
初级用户
倚 天
Credits 106
Posts 2
Joined 2003-06-03 00:00
23-year member
UID 3304
Gender Male
Status Offline


 Earlier we said that under DOS we direct the computer to work by entering commands. But if we just type whatever we want to say into the computer, will the computer understand it?

  Obviously that won't work. A computer under DOS can only understand the meanings of certain special English commands. Only if you enter those commands will the computer obey you; otherwise it will dumbly say: “Bad command or filename.” That means it doesn't understand what you're saying. So, what commands are there under DOS?

  DOS commands are divided into internal commands and external commands. Internal commands are loaded into memory along with command.com, while external commands are separate executable files one by one.

  The internal commands are all concentrated 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, with com and exe as their extensions. They do not stay resident in memory, and are only loaded into memory when the computer needs them.

  Let's first look at a few of the most commonly used commands, so 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 the abbreviation of the English word directory, and is mainly used to display the files and subdirectories in a directory.

  You can try typing dir after the prompt, then press Enter. 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 them clearly, they all whoosh past?

  Don't worry. It's easy if you want to see them clearly. The dir command can take parameters. Type dir/p and try it. Look, now the computer stops after displaying one screenful of content.


  Did you see the English line at the bottom? It means: if you've finished reading this screen, just press any key to see the next screen. Then press a key and try it, any key will do. Well, did it switch to the next screen? Pretty convenient, isn't it?

  If you still think paged display with dir/p is too troublesome, try this command. Type dir/w on 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 file creation times or sizes, then using dir/w to display in short format is a good choice.   

  The dir command can not only check what files are in a directory, it can also view information about a particular file in the directory. For example, if you type dir abc, it will display information about 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 find files. For example, to check whether there is a file named 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, it will display all files whose extension is bat. See 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 is anything. Then dir a.* displays all files whose primary filename is a. If you use dir A*.*, what result will appear? The result is that all files whose primary filename begins with A are displayed. Going a bit further, what does dir *.* mean? Here both the primary filename and the extension can be anything, so it represents all files. Therefore this has the same effect as simply entering dir.    

  Because * can replace any character, we call it a wildcard. Actually, * 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 replace only one 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 no longer have any effect. For example, A*.* and a*b.* are no different at all, but A*.* and A*.com are different, because there is a separator in between, and the effect of * cannot go past the separator.

  In not going beyond the separator, ? is the same as *, but whether ? appears in the primary filename or the extension, the characters after it still take 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.

  One last 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, while ? can appear multiple times as long as the length of the filename and extension is not exceeded. For example, these three filenames a???.b??、a????b?.?c? and ??a?b??c.??d are all allowed.   

  Finally, let's sum up. The greatest use of the dir command is to let you know what exactly 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 first type a: to switch the current drive to A and then type dir. You can directly type dir a: . If you don't believe it, give it a try—but don't forget to insert the floppy disk!

大家好啊!!
希望大家以后给我多多的指教啊!!!
Forum Jump: