Learn Dos Command 2

The basic commands of the DOS system are:

DIR—列出当前目录(文件夹)下的内容(文件和子目录)

​MD--建目录、RD--删目录、CD—进入目录(改变当前目录)

​TYPE—显示(文本)文件的内容

​COPY—文件拷贝命令

​Ctrl+C—终止命令的运行

​HELP—帮助命令

​HELP <命令名>--列出<命令名>所指示的命令的使用方法

Standard input and output steering (standard input steering, standard output steering)

​	标准输入为从(终端)键盘(0号打开文件)输入。

​	标准输出为向(终端)显示器(1号打开文件)输出。

​	标准输入转向就是把标准输入改为从文件输入。

​	标准输出转向就是把标准输出改为向文件输出。

   (特殊文件名代表设备,例如PRN代表打印机)

​ For example:

​		abcd<data123.txt

​		把abcd可执行文件(abcd.bat)的标准输入改为从文件data123.txt输入,“<”为标准输入转向符。



​		dir>dirabc.txt

​		把dir命令的标准输出改为向文件dirabc.txt输出,“>”为标准输出转向符,这样dirabc.txt文件中的内容就是当前目录的列表。



​		dir>PRN

​		把当前目录的列表在打印机输出。

Pipe: | (two vertical bars with a mouth between them on the keyboard)

​	C>C1|C2   把命令C1的标准输出作为命令C2的标准输入

​	例如:

​		C>help|more 把帮助命令分屏输出

​		C>dir|sort  把当前目录的列表排序后在屏幕输出。

​		C>dir|sort>abc  把当前目录的列表排序后输出到文件abc中。

​		C>dir|sort>prn  把当前目录的列表排序后输出到打印机。

​		C>dir|sort|more  把当前目录的列表排序后分屏输出。

DOS batch processing

​ The file with the extension bat in the DOS system and Windows system is called a command file or a batch file, which usually contains a series of DOS commands, such as
abc.bat:

copy c:\f1 d:\
copy c:\f2 d:\
copy c:\f3 d:\

Homework:
After starting the bat file (enter abc or abc.bat on the command line and press Enter, or double-click the abc.bat file in the Windows window), the system will execute each command in sequence, that is, "batch" automatically Processing (copy the files f1, f2, and f3 in the root directory of drive C to the root directory of drive D in turn).

Another example of a bat file is "batch example.BAT", which contains the following commands:

c:		

跳转到C盘的根目录下

cd \	

返回路径的根目录

rd xyz 

删除当前目录下叫做xyz的文件夹

md xyz 

在当前目录下创建一个叫做xyz的子目录

cd xyz 

进入当前目录下叫做xyz的子目录

md xyz1 

在当前目录下创建一个叫做xyz1的子目录

md xyz2 

在当前目录下创建一个叫做xyz2的子目录

 

echo -c:\xyz目录下的目录- >tree123.txt

把前面内容“-c:\xyz目录下的目录-”以覆盖的方式生成或存放在当前目录tree123.txt这个文件内

 

tree c:\xyz>>tree123.txt

以图形显示驱动器或路径的文件夹架构显示在c:xyz这个目录下所有目录并以补充的方式存放在tree123.txt这个文件内

 

echo -c:\xyz下的目录及文件- >>tree123.txt

把前面内容“-c:\xyz目录下的目录-”以补充的方式生成或存放在当前目录tree123.txt这个文件内

 

 

tree c:\xyz>>tree123.txt /f

以图形显示驱动器或路径的文件夹架构显示在c:xyz这个目录下所有目录及目录下的所有文件并以补充的方式存放在tree123.txt这个文件内

 

type tree123.txt 

显示名字叫做tree123.txt的文本的内容

 

copy tree123.txt  d:\t123.txt

把当前目录下叫做tree123.txt的文件复制到D盘的根目录并叫做t123.txt并生成

Please explain what each command does and describe the end result (submit it as an assignment).

Run the batch file containing the above command (you can create a batch file yourself and copy the above command into it), and check whether the running result is consistent with the result you explained.

Guess you like

Origin blog.csdn.net/anxious333/article/details/120410847